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_HALF_H
9 #define EIGEN_SPECIALFUNCTIONS_HALF_H
10 
11 namespace Eigen {
12 namespace numext {
13 
14 #if EIGEN_HAS_C99_MATH
lgamma(const Eigen::half & a)15 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half lgamma(const Eigen::half& a) {
16   return Eigen::half(Eigen::numext::lgamma(static_cast<float>(a)));
17 }
digamma(const Eigen::half & a)18 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half digamma(const Eigen::half& a) {
19   return Eigen::half(Eigen::numext::digamma(static_cast<float>(a)));
20 }
zeta(const Eigen::half & x,const Eigen::half & q)21 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half zeta(const Eigen::half& x, const Eigen::half& q) {
22   return Eigen::half(Eigen::numext::zeta(static_cast<float>(x), static_cast<float>(q)));
23 }
polygamma(const Eigen::half & n,const Eigen::half & x)24 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half polygamma(const Eigen::half& n, const Eigen::half& x) {
25   return Eigen::half(Eigen::numext::polygamma(static_cast<float>(n), static_cast<float>(x)));
26 }
erf(const Eigen::half & a)27 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half erf(const Eigen::half& a) {
28   return Eigen::half(Eigen::numext::erf(static_cast<float>(a)));
29 }
erfc(const Eigen::half & a)30 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half erfc(const Eigen::half& a) {
31   return Eigen::half(Eigen::numext::erfc(static_cast<float>(a)));
32 }
ndtri(const Eigen::half & a)33 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half ndtri(const Eigen::half& a) {
34   return Eigen::half(Eigen::numext::ndtri(static_cast<float>(a)));
35 }
igamma(const Eigen::half & a,const Eigen::half & x)36 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half igamma(const Eigen::half& a, const Eigen::half& x) {
37   return Eigen::half(Eigen::numext::igamma(static_cast<float>(a), static_cast<float>(x)));
38 }
39 template <>
igamma_der_a(const Eigen::half & a,const Eigen::half & x)40 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half igamma_der_a(const Eigen::half& a, const Eigen::half& x) {
41   return Eigen::half(Eigen::numext::igamma_der_a(static_cast<float>(a), static_cast<float>(x)));
42 }
43 template <>
gamma_sample_der_alpha(const Eigen::half & alpha,const Eigen::half & sample)44 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half gamma_sample_der_alpha(const Eigen::half& alpha, const Eigen::half& sample) {
45   return Eigen::half(Eigen::numext::gamma_sample_der_alpha(static_cast<float>(alpha), static_cast<float>(sample)));
46 }
igammac(const Eigen::half & a,const Eigen::half & x)47 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half igammac(const Eigen::half& a, const Eigen::half& x) {
48   return Eigen::half(Eigen::numext::igammac(static_cast<float>(a), static_cast<float>(x)));
49 }
betainc(const Eigen::half & a,const Eigen::half & b,const Eigen::half & x)50 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half betainc(const Eigen::half& a, const Eigen::half& b, const Eigen::half& x) {
51   return Eigen::half(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_HALF_H
59