ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
math.hpp
Go to the documentation of this file.
1/*
2 * $Id: math.hpp 64 2012-01-08 15:32:04Z jdl3 $
3 * Copyright (C) 2010, 2011, 2012 John D Lamb
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef CCGSL_MATH_HPP
21#define CCGSL_MATH_HPP
22
23#include<gsl/gsl_math.h>
24#include"function_scl.hpp"
25#include"function_fdf.hpp"
26#include"sys.hpp"
27
28namespace gsl {
32 namespace math {
36 double const E = M_E;
40 double const LOG2E = M_LOG2E;
44 double const LOG10E = M_LOG10E;
48 double const SQRT2 = M_SQRT2;
52 double const SQRT1_2 = M_SQRT1_2;
56 double const SQRT3 = M_SQRT3;
60 double const PI = M_PI;
64 double const PI_2 = M_PI_2;
68 double const PI_4 = M_PI_4;
72 double const SQRTPI = M_SQRTPI;
76 double const TWO_SQRTPI = M_2_SQRTPI;
80 double const ONE_PI = M_1_PI;
84 double const TWO_PI = M_2_PI;
88 double const LN10 = M_LN10;
92 double const LN2 = M_LN2;
96 double const LNPI = M_LNPI;
100 double const EULER = M_EULER;
101 }
102
103
109 template<typename T>
110 inline bool is_odd( T const& n ){ return n & 1; }
111
117 template<typename T>
118 inline bool is_even( T const& n ){ return not (n & 1); }
119
126 template<typename T>
127 inline short sign( T const& x ){ return x >= 0 ? 1 : -1; }
128
135 inline int is_real( double const x ){ return gsl_finite( x ); }
136
137}
138
139#endif
double const EULER
Euler's constant.
Definition: math.hpp:100
double const LN10
.
Definition: math.hpp:88
double const TWO_SQRTPI
.
Definition: math.hpp:76
double const E
e
Definition: math.hpp:36
double const SQRT1_2
.
Definition: math.hpp:52
double const LNPI
.
Definition: math.hpp:96
double const SQRT3
.
Definition: math.hpp:56
double const PI_4
.
Definition: math.hpp:68
double const LN2
.
Definition: math.hpp:92
double const ONE_PI
.
Definition: math.hpp:80
double const PI
.
Definition: math.hpp:60
double const LOG2E
.
Definition: math.hpp:40
double const TWO_PI
.
Definition: math.hpp:84
double const LOG10E
.
Definition: math.hpp:44
double const PI_2
.
Definition: math.hpp:64
double const SQRT2
.
Definition: math.hpp:48
double const SQRTPI
.
Definition: math.hpp:72
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
Definition: rstat.hpp:299
The gsl package creates an interface to the GNU Scientific Library for C++.
Definition: blas.hpp:34
int is_real(double const x)
Variation on gsl_finite: returns 1 for a real number, 0 for infinite or NaN.
Definition: math.hpp:135
bool is_odd(T const &n)
Check if odd: only really makes sense for integral types.
Definition: math.hpp:110
bool is_even(T const &n)
Check if even: only really makes sense for integral types.
Definition: math.hpp:118
short sign(T const &x)
Find the sign of x: returns +1 for a value of zero to be consistent with GNU Scientific Library.
Definition: math.hpp:127