GeographicLib
1.21
|
Mathematical functions needed by GeographicLib. More...
#include <GeographicLib/Math.hpp>
Public Types | |
typedef double | extended |
typedef double | real |
Static Public Member Functions | |
template<typename T > | |
static T | pi () throw () |
static real | pi () throw () |
template<typename T > | |
static T | degree () throw () |
static real | degree () throw () |
template<typename T > | |
static T | sq (T x) 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 () |
template<typename T > | |
static T | swab (T x) |
Static Public Attributes | |
static const bool | bigendian = WORDS_BIGENDIAN |
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.
Example of use:
// Example of using the GeographicLib::Math class // $Id: 04519bb67e82229a86ee23002ddc27a6b5bb2939 $ #include <iostream> #include <exception> #include <GeographicLib/Math.hpp> using namespace std; using namespace GeographicLib; int main() { try { cout << Math::pi() << " " << Math::sq(Math::pi()) << "\n"; } catch (const exception& e) { cerr << "Caught exception: " << e.what() << "\n"; return 1; } return 0; }
typedef double GeographicLib::Math::extended |
typedef double GeographicLib::Math::real |
static T GeographicLib::Math::pi | ( | ) | throw () [inline, static] |
static real GeographicLib::Math::pi | ( | ) | throw () [inline, static] |
A synonym for pi<real>().
static T GeographicLib::Math::degree | ( | ) | throw () [inline, static] |
static real GeographicLib::Math::degree | ( | ) | throw () [inline, static] |
A synonym for degree<real>().
static T GeographicLib::Math::sq | ( | T | x | ) | throw () [inline, static] |
Square a number.
T | the type of the argument and the returned value. |
[in] | x |
Definition at line 130 of file Math.hpp.
Referenced by GeographicLib::AlbersEqualArea::Forward(), GeographicLib::AlbersEqualArea::Reverse(), GeographicLib::AlbersEqualArea::SetScale(), GeographicLib::Geodesic::GenInverse(), GeographicLib::GravityModel::GravityModel(), GeographicLib::LambertConformalConic::Forward(), GeographicLib::LambertConformalConic::Reverse(), GeographicLib::MagneticModel::FieldComponents(), GeographicLib::NormalGravity::SurfaceGravity(), GeographicLib::NormalGravity::V0(), GeographicLib::NormalGravity::Phi(), GeographicLib::PolarStereographic::Forward(), GeographicLib::PolarStereographic::Reverse(), GeographicLib::TransverseMercator::TransverseMercator(), GeographicLib::TransverseMercator::Forward(), and GeographicLib::TransverseMercator::Reverse().
static T GeographicLib::Math::hypot | ( | T | x, |
T | y | ||
) | throw () [inline, static] |
The hypotenuse function avoiding underflow and overflow.
T | the type of the arguments and the returned value. |
[in] | x | |
[in] | y |
Definition at line 142 of file Math.hpp.
Referenced by GeographicLib::AlbersEqualArea::Reverse(), GeographicLib::Geodesic::GenInverse(), GeographicLib::GravityModel::SphericalAnomaly(), GeographicLib::GravityModel::GeoidHeight(), GeographicLib::GravityModel::Circle(), GeographicLib::LambertConformalConic::Reverse(), GeographicLib::MagneticModel::FieldComponents(), GeographicLib::NormalGravity::V0(), GeographicLib::PolarStereographic::Forward(), GeographicLib::PolarStereographic::Reverse(), GeographicLib::TransverseMercator::Forward(), and GeographicLib::TransverseMercator::Reverse().
static T GeographicLib::Math::expm1 | ( | T | 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.
T | the type of the argument and the returned value. |
[in] | x |
static T GeographicLib::Math::log1p | ( | T | x | ) | throw () [inline, static] |
log(1 + x) accurate near x = 0.
This is taken from 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.
T | the type of the argument and the returned value. |
[in] | x |
Definition at line 224 of file Math.hpp.
Referenced by GeographicLib::LambertConformalConic::Reverse().
static T GeographicLib::Math::asinh | ( | T | 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.
T | the type of the argument and the returned value. |
[in] | x |
Definition at line 256 of file Math.hpp.
Referenced by GeographicLib::LambertConformalConic::Forward(), and GeographicLib::TransverseMercator::Forward().
static T GeographicLib::Math::atanh | ( | T | 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.
T | the type of the argument and the returned value. |
[in] | x |
static T GeographicLib::Math::cbrt | ( | T | x | ) | throw () [inline, static] |
static bool GeographicLib::Math::isfinite | ( | T | x | ) | throw () [inline, static] |
Test for finiteness.
T | the type of the argument. |
[in] | x |
Definition at line 330 of file Math.hpp.
Referenced by GeographicLib::AlbersEqualArea::AlbersEqualArea(), GeographicLib::AlbersEqualArea::SetScale(), GeographicLib::Geocentric::Geocentric(), GeographicLib::Geodesic::Geodesic(), GeographicLib::LambertConformalConic::LambertConformalConic(), GeographicLib::LambertConformalConic::SetScale(), GeographicLib::NormalGravity::NormalGravity(), GeographicLib::PolarStereographic::PolarStereographic(), GeographicLib::PolarStereographic::SetScale(), GeographicLib::TransverseMercator::TransverseMercator(), and GeographicLib::TransverseMercatorExact::TransverseMercatorExact().
static T GeographicLib::Math::NaN | ( | ) | throw () [inline, static] |
static real GeographicLib::Math::NaN | ( | ) | throw () [inline, static] |
A synonym for NaN<real>().
static bool GeographicLib::Math::isnan | ( | T | x | ) | throw () [inline, static] |
static T GeographicLib::Math::infinity | ( | ) | throw () [inline, static] |
static real GeographicLib::Math::infinity | ( | ) | throw () [inline, static] |
A synonym for infinity<real>().
static T GeographicLib::Math::swab | ( | T | x | ) | [inline, static] |
const bool GeographicLib::Math::bigendian = WORDS_BIGENDIAN [static] |
true if the machine is big-endian
Definition at line 99 of file Math.hpp.
Referenced by GeographicLib::Utility::readarray(), and GeographicLib::Utility::writearray().