blob: 2bb017921dd59524fa343ad5ed99d20744bf07c6 [file] [log] [blame]
Austin Schuh189376f2018-12-20 22:11:15 +11001// 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
13namespace Eigen {
14
15namespace internal {
16
17/** \internal \returns the ln(|gamma(\a a)|) (coeff-wise) */
18template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
19Packet plgamma(const Packet& a) { using numext::lgamma; return lgamma(a); }
20
21/** \internal \returns the derivative of lgamma, psi(\a a) (coeff-wise) */
22template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
23Packet pdigamma(const Packet& a) { using numext::digamma; return digamma(a); }
24
25/** \internal \returns the zeta function of two arguments (coeff-wise) */
26template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
27Packet pzeta(const Packet& x, const Packet& q) { using numext::zeta; return zeta(x, q); }
28
29/** \internal \returns the polygamma function (coeff-wise) */
30template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
31Packet ppolygamma(const Packet& n, const Packet& x) { using numext::polygamma; return polygamma(n, x); }
32
33/** \internal \returns the erf(\a a) (coeff-wise) */
34template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
35Packet perf(const Packet& a) { using numext::erf; return erf(a); }
36
37/** \internal \returns the erfc(\a a) (coeff-wise) */
38template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
39Packet perfc(const Packet& a) { using numext::erfc; return erfc(a); }
40
Austin Schuhc55b0172022-02-20 17:52:35 -080041/** \internal \returns the ndtri(\a a) (coeff-wise) */
42template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
43Packet 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
Austin Schuh189376f2018-12-20 22:11:15 +110048/** \internal \returns the incomplete gamma function igamma(\a a, \a x) */
49template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
50Packet pigamma(const Packet& a, const Packet& x) { using numext::igamma; return igamma(a, x); }
51
Austin Schuhc55b0172022-02-20 17:52:35 -080052/** \internal \returns the derivative of the incomplete gamma function
53 * igamma_der_a(\a a, \a x) */
54template <typename Packet>
55EIGEN_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) */
62template <typename Packet>
63EIGEN_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
Austin Schuh189376f2018-12-20 22:11:15 +110067/** \internal \returns the complementary incomplete gamma function igammac(\a a, \a x) */
68template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
69Packet 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) */
72template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
73Packet 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