Eigen  3.2.92
SpecialFunctions.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2015 Eugene Brevdo <ebrevdo@gmail.com>
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_SPECIAL_FUNCTIONS_H
11 #define EIGEN_SPECIAL_FUNCTIONS_H
12 
13 namespace Eigen {
14 namespace internal {
15 
16 /****************************************************************************
17  * Implementation of lgamma *
18  ****************************************************************************/
19 
20 template<typename Scalar>
21 struct lgamma_impl
22 {
23  EIGEN_DEVICE_FUNC
24  static EIGEN_STRONG_INLINE Scalar run(const Scalar&)
25  {
26  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, Scalar>::value == false),
27  THIS_TYPE_IS_NOT_SUPPORTED);
28  return Scalar(0);
29  }
30 };
31 
32 template<typename Scalar>
33 struct lgamma_retval
34 {
35  typedef Scalar type;
36 };
37 
38 #ifdef EIGEN_HAS_C99_MATH
39 template<>
40 struct lgamma_impl<float>
41 {
42  EIGEN_DEVICE_FUNC
43  static EIGEN_STRONG_INLINE double run(const float& x) { return ::lgammaf(x); }
44 };
45 
46 template<>
47 struct lgamma_impl<double>
48 {
49  EIGEN_DEVICE_FUNC
50  static EIGEN_STRONG_INLINE double run(const double& x) { return ::lgamma(x); }
51 };
52 #endif
53 
54 /****************************************************************************
55  * Implementation of erf *
56  ****************************************************************************/
57 
58 template<typename Scalar>
59 struct erf_impl
60 {
61  EIGEN_DEVICE_FUNC
62  static EIGEN_STRONG_INLINE Scalar run(const Scalar&)
63  {
64  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, Scalar>::value == false),
65  THIS_TYPE_IS_NOT_SUPPORTED);
66  return Scalar(0);
67  }
68 };
69 
70 template<typename Scalar>
71 struct erf_retval
72 {
73  typedef Scalar type;
74 };
75 
76 #ifdef EIGEN_HAS_C99_MATH
77 template<>
78 struct erf_impl<float>
79 {
80  EIGEN_DEVICE_FUNC
81  static EIGEN_STRONG_INLINE float run(const float& x) { return ::erff(x); }
82 };
83 
84 template<>
85 struct erf_impl<double>
86 {
87  EIGEN_DEVICE_FUNC
88  static EIGEN_STRONG_INLINE double run(const double& x) { return ::erf(x); }
89 };
90 #endif // EIGEN_HAS_C99_MATH
91 
92 /***************************************************************************
93 * Implementation of erfc *
94 ****************************************************************************/
95 
96 template<typename Scalar>
97 struct erfc_impl
98 {
99  EIGEN_DEVICE_FUNC
100  static EIGEN_STRONG_INLINE Scalar run(const Scalar&)
101  {
102  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, Scalar>::value == false),
103  THIS_TYPE_IS_NOT_SUPPORTED);
104  return Scalar(0);
105  }
106 };
107 
108 template<typename Scalar>
109 struct erfc_retval
110 {
111  typedef Scalar type;
112 };
113 
114 #ifdef EIGEN_HAS_C99_MATH
115 template<>
116 struct erfc_impl<float>
117 {
118  EIGEN_DEVICE_FUNC
119  static EIGEN_STRONG_INLINE float run(const float x) { return ::erfcf(x); }
120 };
121 
122 template<>
123 struct erfc_impl<double>
124 {
125  EIGEN_DEVICE_FUNC
126  static EIGEN_STRONG_INLINE double run(const double x) { return ::erfc(x); }
127 };
128 #endif // EIGEN_HAS_C99_MATH
129 
130 } // end namespace internal
131 
132 
133 namespace numext {
134 
135 template<typename Scalar>
136 EIGEN_DEVICE_FUNC
137 inline EIGEN_MATHFUNC_RETVAL(lgamma, Scalar) lgamma(const Scalar& x)
138 {
139  return EIGEN_MATHFUNC_IMPL(lgamma, Scalar)::run(x);
140 }
141 
142 template<typename Scalar>
143 EIGEN_DEVICE_FUNC
144 inline EIGEN_MATHFUNC_RETVAL(erf, Scalar) erf(const Scalar& x)
145 {
146  return EIGEN_MATHFUNC_IMPL(erf, Scalar)::run(x);
147 }
148 
149 template<typename Scalar>
150 EIGEN_DEVICE_FUNC
151 inline EIGEN_MATHFUNC_RETVAL(erfc, Scalar) erfc(const Scalar& x)
152 {
153  return EIGEN_MATHFUNC_IMPL(erfc, Scalar)::run(x);
154 }
155 
156 } // end namespace numext
157 
158 } // end namespace Eigen
159 
160 #endif // EIGEN_SPECIAL_FUNCTIONS_H
Definition: LDLT.h:16
Definition: Eigen_Colamd.h:54