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);
117 template <
typename T>
118 T gammaPSer(
const T& a,
const T& x)
120 using namespace CDPL;
121 using namespace Math;
125 return std::numeric_limits<T>::quiet_NaN();
134 for (
unsigned int i = 0; i < 100; i++) {
144 return std::numeric_limits<T>::quiet_NaN();
148 template <
typename T>
149 T gammaQContFrac(
const T& a,
const T& x)
151 using namespace CDPL;
152 using namespace Math;
154 static const T EPS = std::numeric_limits<T>::epsilon();
155 static const T FP_MIN = std::numeric_limits<T>::min() / EPS;
162 for (
unsigned int i = 0; i < 100; i++) {
183 return std::numeric_limits<T>::quiet_NaN();
190 template <
typename T>
198 for (
unsigned int i = 2; i <= n; i++)
204 template <
typename T>
211 T tmp = abs_b / abs_a;
219 T tmp = abs_a / abs_b;
224 template <
typename T1,
typename T2>
227 return (b >= 0 ? (a >= 0 ? a : -a) : (a >= 0 ? -a : a));
230 template <
typename T>
233 static const long double cof[6] = {
238 0.1208650973866179e-2,
239 -0.5395239384953e-5};
241 long double ser = 1.000000000190015;
244 long double tmp = x + 5.5;
246 tmp -= (x + 0.5) * std::log(tmp);
248 for (
unsigned int i = 0; i < 6; i++)
251 return T(-tmp + std::log(2.5066282746310005 * ser / x));
254 template <
typename T>
257 if (x <
T(0) || a <=
T(0))
258 return std::numeric_limits<T>::quiet_NaN();
261 return (
T(1) - Detail::gammaPSer(a, x));
263 return Detail::gammaQContFrac(a, x);
266 template <
typename T>
269 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 > &ge)
Returns the sum of all elements of the grid expression ge.
Definition: GridExpression.hpp:818
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 .
The namespace of the Chemical Data Processing Library.
static RealType abs(ConstReference t)
Returns the absolute value of t (std::abs for signed types, the identity for unsigned types).
Definition: TypeTraits.hpp:142
static ValueType sqrt(ConstReference t)
Returns the square root of t.
Definition: TypeTraits.hpp:152