29 #ifndef CDPL_MATH_SPECIALFUNCTIONS_HPP
30 #define CDPL_MATH_SPECIALFUNCTIONS_HPP
68 template <
typename T1,
typename T2>
69 T1
sign(
const T1& a,
const T2& b);
115 template <
typename T>
116 T gammaPSer(
const T& a,
const T& x)
118 using namespace CDPL;
119 using namespace Math;
123 return std::numeric_limits<T>::quiet_NaN();
132 for (
unsigned int i = 0; i < 100; i++) {
142 return std::numeric_limits<T>::quiet_NaN();
146 template <
typename T>
147 T gammaQContFrac(
const T& a,
const T& x)
149 using namespace CDPL;
150 using namespace Math;
152 static const T EPS = std::numeric_limits<T>::epsilon();
153 static const T FP_MIN = std::numeric_limits<T>::min() / EPS;
160 for (
unsigned int i = 0; i < 100; i++) {
181 return std::numeric_limits<T>::quiet_NaN();
188 template <
typename T>
196 for (
unsigned int i = 2; i <= n; i++)
202 template <
typename T>
209 T tmp = abs_b / abs_a;
217 T tmp = abs_a / abs_b;
222 template <
typename T1,
typename T2>
225 return (b >= 0 ? (a >= 0 ? a : -a) : (a >= 0 ? -a : a));
228 template <
typename T>
231 static const long double cof[6] = {
236 0.1208650973866179e-2,
237 -0.5395239384953e-5};
239 long double ser = 1.000000000190015;
242 long double tmp = x + 5.5;
244 tmp -= (x + 0.5) * std::log(tmp);
246 for (
unsigned int i = 0; i < 6; i++)
249 return T(-tmp + std::log(2.5066282746310005 * ser / x));
252 template <
typename T>
255 if (x <
T(0) || a <=
T(0))
256 return std::numeric_limits<T>::quiet_NaN();
259 return (
T(1) - Detail::gammaPSer(a, x));
261 return Detail::gammaQContFrac(a, x);
264 template <
typename T>
267 return (
T(1) / (
T(1) + std::pow(std::abs((x - c) / a),
T(2) * b)));
Definition of type traits.
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
T generalizedBell(const T &x, const T &a, const T &b, const T &c)
Computes the generalized bell function at x.
T factorial(unsigned int n)
Computes the factorial of the non-negative integer n.
T lnGamma(const T &z)
Computes for .
T pythag(const T &a, const T &b)
Computes without destructive underflow or overflow.
GridElementSum< E >::ResultType sum(const GridExpression< E > &e)
Definition: GridExpression.hpp:416
T1 sign(const T1 &a, const T2 &b)
Returns the magnitude of parameter a times the sign of parameter b.
T gammaQ(const T &a, const T &x)
Computes the incomplete gamma function (see [NRIC] for details).
The namespace of the Chemical Data Processing Library.
static RealType abs(ConstReference t)
Definition: TypeTraits.hpp:89
static ValueType sqrt(ConstReference t)
Definition: TypeTraits.hpp:94