Public Types | Static Public Member Functions

GeographicLib::Math Class Reference

Mathematical functions needed by GeographicLib. More...

#include <GeographicLib/Constants.hpp>

List of all members.

Public Types

typedef long double extended
typedef double real

Static Public Member Functions

template<typename T >
static T pi () throw ()
static real pi () throw ()
static extended epi () throw ()
template<typename T >
static T degree () throw ()
static real degree () throw ()
static extended edegree () throw ()
template<typename T >
static T hypot (T x, T y) throw ()
template<typename T >
static T expm1 (T x) throw ()
template<typename T >
static T log1p (T x) throw ()
template<typename T >
static T asinh (T x) throw ()
template<typename T >
static T atanh (T x) throw ()
template<typename T >
static T cbrt (T x) throw ()
template<typename T >
static bool isfinite (T x) throw ()
template<typename T >
static T NaN () throw ()
static real NaN () throw ()
template<typename T >
static bool isnan (T x) throw ()
template<typename T >
static T infinity () throw ()
static real infinity () throw ()

Detailed Description

Mathematical functions needed by GeographicLib.

Define mathematical functions in order to localize system dependencies and to provide generic versions of the functions. In addition define a real type to be used by GeographicLib.

Definition at line 87 of file Constants.hpp.


Member Typedef Documentation

typedef long double GeographicLib::Math::extended

The extended precision type for real numbers, used for some testing. This is long double on computers with this type; otherwise it is double.

Definition at line 101 of file Constants.hpp.

typedef double GeographicLib::Math::real

The real type for GeographicLib. Nearly all the testing has been done with real = double. However, the algorithms should also work with float and long double (where available).

Definition at line 112 of file Constants.hpp.


Member Function Documentation

template<typename T >
static T GeographicLib::Math::pi (  )  throw () [inline, static]
Returns:
pi

Definition at line 125 of file Constants.hpp.

static real GeographicLib::Math::pi (  )  throw () [inline, static]

A synonym for pi<real>().

Definition at line 131 of file Constants.hpp.

static extended GeographicLib::Math::epi (  )  throw () [inline, static]

DEPRECATED A synonym for pi<extened>().

Definition at line 135 of file Constants.hpp.

template<typename T >
static T GeographicLib::Math::degree (  )  throw () [inline, static]
Returns:
the number of radians in a degree.

Definition at line 141 of file Constants.hpp.

static real GeographicLib::Math::degree (  )  throw () [inline, static]

A synonym for degree<real>().

Definition at line 145 of file Constants.hpp.

static extended GeographicLib::Math::edegree (  )  throw () [inline, static]

DEPRECATED A synonym for degree<extened>().

Definition at line 149 of file Constants.hpp.

template<typename T >
static T GeographicLib::Math::hypot ( x,
y 
) throw () [inline, static]
template<typename T >
static T GeographicLib::Math::expm1 ( x  )  throw () [inline, static]

exp(x) - 1 accurate near x = 0. This is taken from N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd Edition (SIAM, 2002), Sec 1.14.1, p 19.

Parameters:
[in] x 
Returns:
exp(x) - 1.

Definition at line 201 of file Constants.hpp.

template<typename T >
static T GeographicLib::Math::log1p ( x  )  throw () [inline, static]

log(x + 1) accurate near x = 0. This is taken See D. Goldberg, What every computer scientist should know about floating-point arithmetic (1991), Theorem 4. See also, Higham (op. cit.), Answer to Problem 1.5, p 528.

Parameters:
[in] x 
Returns:
log(x + 1).

Definition at line 236 of file Constants.hpp.

Referenced by asinh(), atanh(), and GeographicLib::LambertConformalConic::Reverse().

template<typename T >
static T GeographicLib::Math::asinh ( x  )  throw () [inline, static]

The inverse hyperbolic sine function. This is defined in terms of Math::log1p(x) in order to maintain accuracy near x = 0. In addition, the odd parity of the function is enforced.

Parameters:
[in] x 
Returns:
asinh(x).

Definition at line 268 of file Constants.hpp.

References hypot(), and log1p().

Referenced by GeographicLib::TransverseMercator::Forward(), and GeographicLib::LambertConformalConic::Forward().

template<typename T >
static T GeographicLib::Math::atanh ( x  )  throw () [inline, static]

The inverse hyperbolic tangent function. This is defined in terms of Math::log1p(x) in order to maintain accuracy near x = 0. In addition, the odd parity of the function is enforced.

Parameters:
[in] x 
Returns:
atanh(x).

Definition at line 295 of file Constants.hpp.

References log1p().

template<typename T >
static T GeographicLib::Math::cbrt ( x  )  throw () [inline, static]

The cube root function.

Parameters:
[in] x 
Returns:
the real cube root of x.

Definition at line 320 of file Constants.hpp.

template<typename T >
static bool GeographicLib::Math::isfinite ( x  )  throw () [inline, static]

Test for finiteness.

Parameters:
[in] x 
Returns:
true if number is finite, false if NaN or infinite.

Definition at line 342 of file Constants.hpp.

Referenced by GeographicLib::DMS::Encode().

template<typename T >
static T GeographicLib::Math::NaN (  )  throw () [inline, static]

The NaN (not a number)

Returns:
NaN if available, otherwise return the max real.

Definition at line 358 of file Constants.hpp.

Referenced by GeographicLib::UTMUPS::Forward(), GeographicLib::Geodesic::GenInverse(), GeographicLib::UTMUPS::Reverse(), and GeographicLib::MGRS::Reverse().

static real GeographicLib::Math::NaN (  )  throw () [inline, static]

A synonym for NaN<real>().

Definition at line 366 of file Constants.hpp.

template<typename T >
static bool GeographicLib::Math::isnan ( x  )  throw () [inline, static]

Test for NaN.

Parameters:
[in] x 
Returns:
true if argument is a NaN.

Definition at line 375 of file Constants.hpp.

Referenced by GeographicLib::MGRS::Forward(), main(), GeographicLib::UTMUPS::Reverse(), and GeographicLib::UTMUPS::StandardZone().

template<typename T >
static T GeographicLib::Math::infinity (  )  throw () [inline, static]

Infinity

Returns:
infinity if available, otherwise return the max real.

Definition at line 389 of file Constants.hpp.

static real GeographicLib::Math::infinity (  )  throw () [inline, static]

A synonym for infinity<real>().

Definition at line 397 of file Constants.hpp.


The documentation for this class was generated from the following file: