78 else if (arg <= -1.0) {
82 #if defined(G_USE_ASIN_FOR_ACOS)
137 if (fmod(angle, 90.0) == 0.0) {
138 int i =
std::abs((
int)std::floor(angle/90.0 + 0.5)) % 4;
166 if (fmod(angle, 90.0) == 0.0) {
167 int i =
std::abs((
int)std::floor(angle/90.0 - 0.5))%4;
195 double resid = fmod(angle, 360.0);
196 if (resid == 0.0 ||
std::abs(resid) == 180.0) {
199 else if (resid == 45.0 || resid == 225.0) {
202 else if (resid == -135.0 || resid == -315.0) {
221 const double wcstrig_tol = 1.0e-10;
225 if (value-1.0 < wcstrig_tol) {
229 else if (value == 0.0) {
232 else if (value <= -1.0) {
233 if (value+1.0 > -wcstrig_tol) {
253 const double wcstrig_tol = 1.0e-10;
257 if (value+1.0 > -wcstrig_tol) {
261 else if (value == 0.0) {
264 else if (value >= 1.0) {
265 if (value-1.0 < wcstrig_tol) {
288 else if (value == 0.0) {
291 else if (value == 1.0) {
346 if (fmod(angle, 90.0) == 0.0) {
347 int i =
std::abs((
int)std::floor(angle/90.0 + 0.5)) % 4;
354 *s = (angle > 0.0) ? 1.0 : -1.0;
362 *s = (angle > 0.0) ? -1.0 : 1.0;
370 *c =
std::cos(angle * gammalib::deg2rad);
386 static const double cof[6] = { 76.18009172947146,
390 0.1208650973866179e-2,
391 -0.5395239384953e-5};
398 double d = 1.000000000190015;
399 for (
int i = 0; i < 6; ++i) {
402 double result =
std::log(2.5066282746310005 * d/a) - c;
421 double t = 1.0/(1.0+0.5*z);
424 double tau = t*
std::exp(-z*z - 1.26551223 + t *
432 (-0.82215223 + t * 0.17087277)))))))));
435 double result = (arg >= 0.0) ? 1.0 - tau : tau - 1.0;
453 return (1.0 -
erf(arg));
466 static const double a[4] = { 0.886226899, -1.645349621, 0.914624893,
468 static const double b[4] = {-2.118377725, 1.442710462, -0.329097515,
470 static const double c[4] = {-1.970840454, -1.624906493, 3.429567803,
472 static const double d[2] = { 3.543889200, 1.637067800};
480 result = std::atof(
"NAN");
485 result =
copysign(1.0, arg) * DBL_MAX;
493 double z = arg * arg;
494 double num = (((a[3]*z + a[2])*z + a[1])*z + a[0]);
495 double dem = ((((b[3]*z + b[2])*z + b[1])*z +b[0])*z + 1.0);
496 result = arg * num/dem;
500 double num = ((c[3]*z + c[2])*z + c[1])*z + c[0];
501 double dem = (d[1]*z + d[0])*z + 1.0;
502 result = (
copysign(1.0, arg)) * num/dem;
506 result -= (
erf(result) - arg) / (e *
std::exp(-result*result));
507 result -= (
erf(result) - arg) / (e *
std::exp(-result*result));
533 result = (v1 < v2) ? v1 : std::fmod(v1,v2);
536 double tmp = std::fmod(v1,v2) + v2;
537 result = (tmp == v2) ? 0.0 : tmp;
575 double slope = fratio / xratio;
576 double slopep1 = slope + 1.0;
582 integral = f1 / slopep1 * (x2 *
std::pow(x2x1, slope) - x1);
585 integral = f1 * x1 * xratio;
610 double xmin = x1 *
norm;
611 double xmax = x2 *
norm;
double tand(const double &angle)
Compute tangens of angle in degrees.
double norm(const GVector &vector)
Computes vector norm.
double erf(const double &arg)
Computes error function.
GVector abs(const GVector &vector)
Computes absolute of vector elements.
double gauss_integral(const double &x1, const double &x2)
Returns the integral of a Gaussian function.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
double modulo(const double &v1, const double &v2)
Returns the remainder of the division.
double acos(const double &arg)
Computes acos by avoiding NaN due to rounding errors.
double atand(const double &value)
Compute arc tangens in degrees.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
double acosd(const double &value)
Compute arc cosine in degrees.
GVector tan(const GVector &vector)
Computes tangens of vector elements.
double erfinv(const double &arg)
Computes inverse error function.
void sincosd(const double &angle, double *s, double *c)
Compute sine and cosine of angle in degrees.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
double angle(const GVector &a, const GVector &b)
Computes angle between vectors.
double erfc(const double &arg)
Computes complementary error function.
GVector asin(const GVector &vector)
Computes arcsin of vector elements.
double plaw_integral(const double &x1, const double &f1, const double &x2, const double &f2)
Returns the integral of a power law.
double gammln(const double &arg)
Computes logarithm of gamma function.
double atan2d(const double &y, const double &x)
Compute arc tangens in degrees.
double cosd(const double &angle)
Compute cosine of angle in degrees.
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
GVector sin(const GVector &vector)
Computes sine of vector elements.
double asind(const double &value)
Compute arc sine in degrees.
double atan2(const double &y, const double &x)
Compute arc tangens in radians.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
GVector atan(const GVector &vector)
Computes arctan of vector elements.
double sind(const double &angle)
Compute sine of angle in degrees.
Mathematical function definitions.