|
| 1 | +// This file is part of Eigen, a lightweight C++ template library |
| 2 | +// for linear algebra. |
| 3 | +// |
| 4 | +// Copyright (C) 2006-2010 Benoit Jacob <[email protected]> |
| 5 | +// Copyright (C) 2015 Eugene Brevdo <[email protected]> |
| 6 | +// |
| 7 | +// This Source Code Form is subject to the terms of the Mozilla |
| 8 | +// Public License v. 2.0. If a copy of the MPL was not distributed |
| 9 | +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 10 | + |
| 11 | +#ifndef EIGEN_SPECIALFUNCTIONS_H |
| 12 | +#define EIGEN_SPECIALFUNCTIONS_H |
| 13 | + |
| 14 | +namespace Eigen { |
| 15 | + |
| 16 | +namespace internal { |
| 17 | + |
| 18 | +template <typename Scalar> |
| 19 | +EIGEN_STRONG_INLINE Scalar __lgamma(Scalar x) { |
| 20 | + EIGEN_STATIC_ASSERT((internal::is_same<Scalar, Scalar>::value == false), |
| 21 | + THIS_TYPE_IS_NOT_SUPPORTED); |
| 22 | +} |
| 23 | + |
| 24 | +template <> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float __lgamma<float>(float x) { return lgammaf(x); } |
| 25 | +template <> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double __lgamma<double>(double x) { return lgamma(x); } |
| 26 | + |
| 27 | +template <typename Scalar> |
| 28 | +EIGEN_STRONG_INLINE Scalar __erf(Scalar x) { |
| 29 | + EIGEN_STATIC_ASSERT((internal::is_same<Scalar, Scalar>::value == false), |
| 30 | + THIS_TYPE_IS_NOT_SUPPORTED); |
| 31 | +} |
| 32 | + |
| 33 | +template <> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float __erf<float>(float x) { return erff(x); } |
| 34 | +template <> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double __erf<double>(double x) { return erf(x); } |
| 35 | + |
| 36 | +template <typename Scalar> |
| 37 | +EIGEN_STRONG_INLINE Scalar __erfc(Scalar x) { |
| 38 | + EIGEN_STATIC_ASSERT((internal::is_same<Scalar, Scalar>::value == false), |
| 39 | + THIS_TYPE_IS_NOT_SUPPORTED); |
| 40 | +} |
| 41 | + |
| 42 | +template <> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float __erfc<float>(float x) { return erfcf(x); } |
| 43 | +template <> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double __erfc<double>(double x) { return erfc(x); } |
| 44 | + |
| 45 | +} // end namespace internal |
| 46 | + |
| 47 | +/**************************************************************************** |
| 48 | +* Implementations * |
| 49 | +****************************************************************************/ |
| 50 | + |
| 51 | +namespace internal { |
| 52 | + |
| 53 | +/**************************************************************************** |
| 54 | +* Implementation of lgamma * |
| 55 | +****************************************************************************/ |
| 56 | + |
| 57 | +template<typename Scalar> |
| 58 | +struct lgamma_impl |
| 59 | +{ |
| 60 | + EIGEN_DEVICE_FUNC |
| 61 | + static EIGEN_STRONG_INLINE Scalar run(const Scalar& x) |
| 62 | + { |
| 63 | + return __lgamma<Scalar>(x); |
| 64 | + } |
| 65 | +}; |
| 66 | + |
| 67 | +template<typename Scalar> |
| 68 | +struct lgamma_retval |
| 69 | +{ |
| 70 | + typedef Scalar type; |
| 71 | +}; |
| 72 | + |
| 73 | +/**************************************************************************** |
| 74 | +* Implementation of erf * |
| 75 | +****************************************************************************/ |
| 76 | + |
| 77 | +template<typename Scalar> |
| 78 | +struct erf_impl |
| 79 | +{ |
| 80 | + EIGEN_DEVICE_FUNC |
| 81 | + static EIGEN_STRONG_INLINE Scalar run(const Scalar& x) |
| 82 | + { |
| 83 | + return __erf<Scalar>(x); |
| 84 | + } |
| 85 | +}; |
| 86 | + |
| 87 | +template<typename Scalar> |
| 88 | +struct erf_retval |
| 89 | +{ |
| 90 | + typedef Scalar type; |
| 91 | +}; |
| 92 | + |
| 93 | +/**************************************************************************** |
| 94 | +* Implementation of erfc * |
| 95 | +****************************************************************************/ |
| 96 | + |
| 97 | +template<typename Scalar> |
| 98 | +struct erfc_impl |
| 99 | +{ |
| 100 | + EIGEN_DEVICE_FUNC |
| 101 | + static EIGEN_STRONG_INLINE Scalar run(const Scalar& x) |
| 102 | + { |
| 103 | + return __erfc<Scalar>(x); |
| 104 | + } |
| 105 | +}; |
| 106 | + |
| 107 | +template<typename Scalar> |
| 108 | +struct erfc_retval |
| 109 | +{ |
| 110 | + typedef Scalar type; |
| 111 | +}; |
| 112 | + |
| 113 | +} // end namespace internal |
| 114 | + |
| 115 | +namespace numext { |
| 116 | + |
| 117 | +template<typename Scalar> |
| 118 | +EIGEN_DEVICE_FUNC |
| 119 | +inline EIGEN_MATHFUNC_RETVAL(lgamma, Scalar) lgamma(const Scalar& x) |
| 120 | +{ |
| 121 | + return EIGEN_MATHFUNC_IMPL(lgamma, Scalar)::run(x); |
| 122 | +} |
| 123 | + |
| 124 | +template<typename Scalar> |
| 125 | +EIGEN_DEVICE_FUNC |
| 126 | +inline EIGEN_MATHFUNC_RETVAL(erf, Scalar) erf(const Scalar& x) |
| 127 | +{ |
| 128 | + return EIGEN_MATHFUNC_IMPL(erf, Scalar)::run(x); |
| 129 | +} |
| 130 | + |
| 131 | +template<typename Scalar> |
| 132 | +EIGEN_DEVICE_FUNC |
| 133 | +inline EIGEN_MATHFUNC_RETVAL(erfc, Scalar) erfc(const Scalar& x) |
| 134 | +{ |
| 135 | + return EIGEN_MATHFUNC_IMPL(erfc, Scalar)::run(x); |
| 136 | +} |
| 137 | + |
| 138 | +} // end namespace numext |
| 139 | + |
| 140 | +} // end namespace Eigen |
| 141 | + |
| 142 | +#endif // EIGEN_SPECIALFUNCTIONS_H |
0 commit comments