-
Notifications
You must be signed in to change notification settings - Fork 0
Mathematical functions
These typedefs and constants are defined in Common/number.h
-
typedef double real
This typedef is used extensively in GLS++, to abstract away the difference between single and double precision floating point values.
Const definitions for several common values
const real realZero = 0.0const real realOne = 1.0const real realEmpty = GSL_NANconst real NaN = GSL_NANconst real realPlusInf = GSL_POSINFconst real realMinusInf = GSL_NEGINF
Functions for testing validity of numbers
bool gsl::is_empty( real x )bool gsl::is_nan( real x )bool gsl::is_finite( real x)
Mathematical constants
-
gsl::e
Base of natural logarithm -
gsl::log2e
Base two logarithm of e -
gsl::log10e
Base ten logarithm of e -
gsl::sqrt2
Square-root of two -
gsl::sqrt_half
Square-root of one-half -
gsl::sqrt3
Square-root of three -
gsl::pi
pi -
gsl::half_pi
pi / 2 -
gsl::quarter_pi
pi / 4 -
gsl::sqrt_pi
square-root of pi -
gsl::two_over_sqrt_pi
two divided by the square-root of pi -
gsl::one_over_pi
recprocal of pi -
gsl::two_over_pi
twice the reciprocal of pi -
gsl::ln10
Natural logarithm of ten -
gsl::ln2
Natural logarithm of two -
gsl::ln_pi
Natural logarithn of pi -
gsl::euler
Euler's constant
This class stores a floating point number and allows easy access to the exponent and mantissa, as well as conversion to and from real values. gsl::floating_point is defined in Common/number.h.
-
class floating_point
The floating point class -
gsl::floating_point::floating_point()
Default constructor -
gsl::floating_point::floating_point( real m, int e )
Construct a floating point number from mantissa, m, and exponent, e -
gsl::floating_point::floating_point( real x )
Construct a floating point number from a real value, x -
gsl::floating_point::operator real()
Cast a floating point number to a real value -
`gsl::floating_point& gsl::floating_point::operator=( const gsl::floating_point& right )
Equality operator -
gsl::sign_type gsl::floating_point::sign() const
Determine the sign of the floating point number. Returnsgsl::positiveif the sign of the floating point value is positive andgsl::negativeif it is negative -
real& f()
Returns a reference to the fraction component of the floating point number -
const real& f() const
returns a const reference to the fraction component of the floating point number -
int& e()
Returns a reference to the exponent of the floating point number -
const int& e() const
Returns a const reference to the exponent of the floating point number
These routines provide wrappers to native GSL functions, which are in turn portable implementations of functions found in the BSD math library. If compiled with the option GSLPP_INLINE, these functions are in-line calls to the underlying GSL functions. These functions are defined in Common/math.h.
-
real gsl::log1p( real x )
Computes the value of log(1 + x) in a way that is accurate for small values of x -
real gsl::expm1( real x )
Compute the value of exp(x) - 1 in a way that is accurate for small values of x -
real gsl::hypot( real x, real y )
Compute the value of sqrt(x2 + y2) in a way that avoids overflow -
real gsl::ldexp( const gsl::floating_point& x )
Compute the value of f × 2e -
gsl::floating_point gsl::frexp( real x )
Split the number x into its normalised fraction f and exponent e, such that x = f × 2e and 0.5 ≤ f < 0.5. If x = 0, both f & e are set to zero.
These functions wrap the GSL small integer power functions. If the compilation option GSLPP_INLINE is defined, then the calls to the underlying GSL functions are in-lined. These functions are defined in Common/math.h.
-
real pow( real x, int n )
Computes the power xn for integer n. The power is computed efficiently — for example, x8 is computed as ((x2)2)2, requiring only three multiplications -
real gsl::pow_2( real x ) -
real gsl::pow_3( real x ) -
real gsl::pow_4( real x ) -
real gsl::pow_5( real x ) -
real gsl::pow_6( real x ) -
real gsl::pow_7( real x ) -
real gsl::pow_8( real x ) -
real gsl::pow_9( real x )
These functions are defined in Common/math.h.
-
gsl::sign_type sign( real x )
Returnsgsl::positiveif x ≥ 0 andgsl::negativeotherwise.
bool gsl::is_odd( int x )bool gsl::is_even( int x )
These functions just wrap std::min & std::max. If GSLPP__INLINE is defined, these functions are in-lined. These functions are defined in Common/math.h
template< typename T > T min( T x1, T x2 )template< typename T > T max( T x1, T x2 )
-
gsl::equality_type fcmp( real x, real y, real epsilon)
Determine whether x & y are approximately equal to a relative accuracy ε. The relative accuracy is measured using an interval size 2δ, where δ = 2kε and k is the maximum base-2 exponent of x & y, as computed by the functionfrexp. Returnsgsl::equal_toif x & y are determined equal,gsl::less_thanif x < y andgsl::greater_thanif x > y