SpecialFunctionsPacketMath.h (3713B)
1 // This file is part of Eigen, a lightweight C++ template library 2 // for linear algebra. 3 // 4 // Copyright (C) 2016 Gael Guennebaud <gael.guennebaud@inria.fr> 5 // 6 // This Source Code Form is subject to the terms of the Mozilla 7 // Public License v. 2.0. If a copy of the MPL was not distributed 8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 10 #ifndef EIGEN_SPECIALFUNCTIONS_PACKETMATH_H 11 #define EIGEN_SPECIALFUNCTIONS_PACKETMATH_H 12 13 namespace Eigen { 14 15 namespace internal { 16 17 /** \internal \returns the ln(|gamma(\a a)|) (coeff-wise) */ 18 template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 19 Packet plgamma(const Packet& a) { using numext::lgamma; return lgamma(a); } 20 21 /** \internal \returns the derivative of lgamma, psi(\a a) (coeff-wise) */ 22 template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 23 Packet pdigamma(const Packet& a) { using numext::digamma; return digamma(a); } 24 25 /** \internal \returns the zeta function of two arguments (coeff-wise) */ 26 template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 27 Packet pzeta(const Packet& x, const Packet& q) { using numext::zeta; return zeta(x, q); } 28 29 /** \internal \returns the polygamma function (coeff-wise) */ 30 template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 31 Packet ppolygamma(const Packet& n, const Packet& x) { using numext::polygamma; return polygamma(n, x); } 32 33 /** \internal \returns the erf(\a a) (coeff-wise) */ 34 template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 35 Packet perf(const Packet& a) { using numext::erf; return erf(a); } 36 37 /** \internal \returns the erfc(\a a) (coeff-wise) */ 38 template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 39 Packet perfc(const Packet& a) { using numext::erfc; return erfc(a); } 40 41 /** \internal \returns the ndtri(\a a) (coeff-wise) */ 42 template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 43 Packet pndtri(const Packet& a) { 44 typedef typename unpacket_traits<Packet>::type ScalarType; 45 using internal::generic_ndtri; return generic_ndtri<Packet, ScalarType>(a); 46 } 47 48 /** \internal \returns the incomplete gamma function igamma(\a a, \a x) */ 49 template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 50 Packet pigamma(const Packet& a, const Packet& x) { using numext::igamma; return igamma(a, x); } 51 52 /** \internal \returns the derivative of the incomplete gamma function 53 * igamma_der_a(\a a, \a x) */ 54 template <typename Packet> 55 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pigamma_der_a(const Packet& a, const Packet& x) { 56 using numext::igamma_der_a; return igamma_der_a(a, x); 57 } 58 59 /** \internal \returns compute the derivative of the sample 60 * of Gamma(alpha, 1) random variable with respect to the parameter a 61 * gamma_sample_der_alpha(\a alpha, \a sample) */ 62 template <typename Packet> 63 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pgamma_sample_der_alpha(const Packet& alpha, const Packet& sample) { 64 using numext::gamma_sample_der_alpha; return gamma_sample_der_alpha(alpha, sample); 65 } 66 67 /** \internal \returns the complementary incomplete gamma function igammac(\a a, \a x) */ 68 template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 69 Packet pigammac(const Packet& a, const Packet& x) { using numext::igammac; return igammac(a, x); } 70 71 /** \internal \returns the complementary incomplete gamma function betainc(\a a, \a b, \a x) */ 72 template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 73 Packet pbetainc(const Packet& a, const Packet& b,const Packet& x) { using numext::betainc; return betainc(a, b, x); } 74 75 } // end namespace internal 76 77 } // end namespace Eigen 78 79 #endif // EIGEN_SPECIALFUNCTIONS_PACKETMATH_H