Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame^] | 1 | // This file is part of Eigen, a lightweight C++ template library |
| 2 | // for linear algebra. |
| 3 | // |
| 4 | // This Source Code Form is subject to the terms of the Mozilla |
| 5 | // Public License v. 2.0. If a copy of the MPL was not distributed |
| 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 | |
| 8 | #ifndef EIGEN_SPECIALFUNCTIONS_BFLOAT16_H |
| 9 | #define EIGEN_SPECIALFUNCTIONS_BFLOAT16_H |
| 10 | |
| 11 | namespace Eigen { |
| 12 | namespace numext { |
| 13 | |
| 14 | #if EIGEN_HAS_C99_MATH |
| 15 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 lgamma(const Eigen::bfloat16& a) { |
| 16 | return Eigen::bfloat16(Eigen::numext::lgamma(static_cast<float>(a))); |
| 17 | } |
| 18 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 digamma(const Eigen::bfloat16& a) { |
| 19 | return Eigen::bfloat16(Eigen::numext::digamma(static_cast<float>(a))); |
| 20 | } |
| 21 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 zeta(const Eigen::bfloat16& x, const Eigen::bfloat16& q) { |
| 22 | return Eigen::bfloat16(Eigen::numext::zeta(static_cast<float>(x), static_cast<float>(q))); |
| 23 | } |
| 24 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 polygamma(const Eigen::bfloat16& n, const Eigen::bfloat16& x) { |
| 25 | return Eigen::bfloat16(Eigen::numext::polygamma(static_cast<float>(n), static_cast<float>(x))); |
| 26 | } |
| 27 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 erf(const Eigen::bfloat16& a) { |
| 28 | return Eigen::bfloat16(Eigen::numext::erf(static_cast<float>(a))); |
| 29 | } |
| 30 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 erfc(const Eigen::bfloat16& a) { |
| 31 | return Eigen::bfloat16(Eigen::numext::erfc(static_cast<float>(a))); |
| 32 | } |
| 33 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 ndtri(const Eigen::bfloat16& a) { |
| 34 | return Eigen::bfloat16(Eigen::numext::ndtri(static_cast<float>(a))); |
| 35 | } |
| 36 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 igamma(const Eigen::bfloat16& a, const Eigen::bfloat16& x) { |
| 37 | return Eigen::bfloat16(Eigen::numext::igamma(static_cast<float>(a), static_cast<float>(x))); |
| 38 | } |
| 39 | template <> |
| 40 | EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 igamma_der_a(const Eigen::bfloat16& a, const Eigen::bfloat16& x) { |
| 41 | return Eigen::bfloat16(Eigen::numext::igamma_der_a(static_cast<float>(a), static_cast<float>(x))); |
| 42 | } |
| 43 | template <> |
| 44 | EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 gamma_sample_der_alpha(const Eigen::bfloat16& alpha, const Eigen::bfloat16& sample) { |
| 45 | return Eigen::bfloat16(Eigen::numext::gamma_sample_der_alpha(static_cast<float>(alpha), static_cast<float>(sample))); |
| 46 | } |
| 47 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 igammac(const Eigen::bfloat16& a, const Eigen::bfloat16& x) { |
| 48 | return Eigen::bfloat16(Eigen::numext::igammac(static_cast<float>(a), static_cast<float>(x))); |
| 49 | } |
| 50 | template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::bfloat16 betainc(const Eigen::bfloat16& a, const Eigen::bfloat16& b, const Eigen::bfloat16& x) { |
| 51 | return Eigen::bfloat16(Eigen::numext::betainc(static_cast<float>(a), static_cast<float>(b), static_cast<float>(x))); |
| 52 | } |
| 53 | #endif |
| 54 | |
| 55 | } // end namespace numext |
| 56 | } // end namespace Eigen |
| 57 | |
| 58 | #endif // EIGEN_SPECIALFUNCTIONS_BFLOAT16_H |