GeographicLib
1.35
|
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 T | sum (T u, T v, T &t) throw () |
template<typename T > | |
static T | AngNormalize (T x) throw () |
template<typename T > | |
static T | AngNormalize2 (T x) throw () |
template<typename T > | |
static T | AngDiff (T x, T y) 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 int | extradigits |
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:
typedef double GeographicLib::Math::extended |
typedef double GeographicLib::Math::real |
|
inlinestatic |
|
inlinestatic |
A synonym for pi<real>().
|
inlinestatic |
|
inlinestatic |
A synonym for degree<real>().
|
inlinestatic |
Square a number.
T | the type of the argument and the returned value. |
[in] | x |
Definition at line 153 of file Math.hpp.
Referenced by GeographicLib::Ellipsoid::Area(), GeographicLib::SphericalEngine::Circle(), GeographicLib::MagneticModel::FieldComponents(), GeographicLib::Ellipsoid::FlatteningToSecondEccentricitySq(), GeographicLib::Ellipsoid::FlatteningToThirdEccentricitySq(), GeographicLib::PolarStereographic::Forward(), GeographicLib::TransverseMercator::Forward(), GeographicLib::AlbersEqualArea::Forward(), GeographicLib::LambertConformalConic::Forward(), GeographicLib::GeodesicExact::GenInverse(), GeographicLib::Geodesic::GenInverse(), GeographicLib::GeodesicLineExact::GenPosition(), GeographicLib::GeodesicLine::GenPosition(), GeographicLib::GeodesicLine::GeodesicLine(), GeographicLib::GeodesicLineExact::GeodesicLineExact(), GeographicLib::GravityModel::GravityModel(), GeographicLib::Ellipsoid::MeridionalCurvatureRadius(), GeographicLib::Ellipsoid::NormalCurvatureRadius(), GeographicLib::NormalGravity::Phi(), GeographicLib::EllipticFunction::Reset(), GeographicLib::PolarStereographic::Reverse(), GeographicLib::TransverseMercator::Reverse(), GeographicLib::AlbersEqualArea::Reverse(), GeographicLib::LambertConformalConic::Reverse(), GeographicLib::EllipticFunction::RG(), GeographicLib::EllipticFunction::RJ(), GeographicLib::AlbersEqualArea::SetScale(), GeographicLib::NormalGravity::SurfaceGravity(), GeographicLib::Ellipsoid::TransverseCurvatureRadius(), GeographicLib::TransverseMercator::TransverseMercator(), GeographicLib::NormalGravity::V0(), GeographicLib::SphericalEngine::Value(), and GeographicLib::Ellipsoid::Volume().
|
inlinestatic |
The hypotenuse function avoiding underflow and overflow.
T | the type of the arguments and the returned value. |
[in] | x | |
[in] | y |
Definition at line 165 of file Math.hpp.
Referenced by GeographicLib::SphericalEngine::Circle(), GeographicLib::GravityModel::Circle(), GeographicLib::Ellipsoid::CircleHeight(), GeographicLib::Ellipsoid::CircleRadius(), GeographicLib::MagneticModel::FieldComponents(), GeographicLib::PolarStereographic::Forward(), GeographicLib::TransverseMercator::Forward(), GeographicLib::GeodesicExact::GenInverse(), GeographicLib::Geodesic::GenInverse(), GeographicLib::GeodesicLineExact::GenPosition(), GeographicLib::GeodesicLine::GenPosition(), GeographicLib::GeodesicLine::GeodesicLine(), GeographicLib::GeodesicLineExact::GeodesicLineExact(), GeographicLib::GravityModel::GeoidHeight(), GeographicLib::AzimuthalEquidistant::Reverse(), GeographicLib::PolarStereographic::Reverse(), GeographicLib::TransverseMercator::Reverse(), GeographicLib::Gnomonic::Reverse(), GeographicLib::AlbersEqualArea::Reverse(), GeographicLib::LambertConformalConic::Reverse(), GeographicLib::GravityModel::SphericalAnomaly(), GeographicLib::NormalGravity::V0(), and GeographicLib::SphericalEngine::Value().
|
inlinestatic |
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 |
|
inlinestatic |
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 256 of file Math.hpp.
Referenced by GeographicLib::LambertConformalConic::Reverse().
|
inlinestatic |
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 288 of file Math.hpp.
Referenced by GeographicLib::TransverseMercator::Forward(), GeographicLib::LambertConformalConic::Forward(), and GeographicLib::Ellipsoid::IsometricLatitude().
|
inlinestatic |
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 |
Definition at line 315 of file Math.hpp.
Referenced by GeographicLib::Ellipsoid::Area(), and GeographicLib::EllipticFunction::RC().
|
inlinestatic |
|
inlinestatic |
The error-free sum of two numbers.
T | the type of the argument and the returned value. |
[in] | u | |
[in] | v | |
[out] | t | the exact error given by (u + v) - s. |
See D. E. Knuth, TAOCP, Vol 2, 4.2.2, Theorem B. (Note that t can be the same as one of the first two arguments.)
|
inlinestatic |
Normalize an angle (restricted input range).
T | the type of the argument and returned value. |
[in] | x | the angle in degrees. |
x must lie in [−540°, 540°).
Definition at line 388 of file Math.hpp.
Referenced by GeographicLib::PolygonArea::AddPoint(), GeographicLib::Geoid::CacheArea(), GeographicLib::DMS::DecodeAzimuth(), GeographicLib::DMS::DecodeLatLon(), GeographicLib::Geohash::Forward(), GeographicLib::PolarStereographic::Forward(), GeographicLib::TransverseMercator::Forward(), GeographicLib::CassiniSoldner::Forward(), GeographicLib::TransverseMercatorExact::Forward(), GeographicLib::AlbersEqualArea::Forward(), GeographicLib::LambertConformalConic::Forward(), GeographicLib::GeodesicExact::GenInverse(), GeographicLib::Geodesic::GenInverse(), GeographicLib::GeodesicLineExact::GenPosition(), GeographicLib::GeodesicLine::GenPosition(), GeographicLib::GeodesicLine::GeodesicLine(), GeographicLib::GeodesicLineExact::GeodesicLineExact(), main(), GeographicLib::LocalCartesian::Reset(), GeographicLib::TransverseMercator::Reverse(), GeographicLib::TransverseMercatorExact::Reverse(), GeographicLib::AlbersEqualArea::Reverse(), and GeographicLib::LambertConformalConic::Reverse().
|
inlinestatic |
Normalize an arbitrary angle.
T | the type of the argument and returned value. |
[in] | x | the angle in degrees. |
The range of x is unrestricted.
Definition at line 400 of file Math.hpp.
Referenced by GeographicLib::GeodesicLineExact::GenPosition(), and GeographicLib::GeodesicLine::GenPosition().
|
inlinestatic |
Difference of two angles reduced to [−180°, 180°]
T | the type of the arguments and returned value. |
[in] | x | the first angle in degrees. |
[in] | y | the second angle in degrees. |
x and y must both lie in [−180°, 180°]. The result is equivalent to computing the difference exactly, reducing it to (−180°, 180°] and rounding the result. Note that this prescription allows −180° to be returned (e.g., if x is tiny and negative and y = 180°).
Definition at line 418 of file Math.hpp.
Referenced by GeographicLib::TransverseMercator::Forward(), GeographicLib::CassiniSoldner::Forward(), GeographicLib::TransverseMercatorExact::Forward(), GeographicLib::AlbersEqualArea::Forward(), GeographicLib::LambertConformalConic::Forward(), GeographicLib::GeodesicExact::GenInverse(), and GeographicLib::Geodesic::GenInverse().
|
inlinestatic |
Test for finiteness.
T | the type of the argument. |
[in] | x |
Definition at line 435 of file Math.hpp.
Referenced by GeographicLib::AlbersEqualArea::AlbersEqualArea(), GeographicLib::DMS::Encode(), GeographicLib::Geocentric::Geocentric(), GeographicLib::Geodesic::Geodesic(), GeographicLib::GeodesicExact::GeodesicExact(), GeographicLib::LambertConformalConic::LambertConformalConic(), GeographicLib::NormalGravity::NormalGravity(), GeographicLib::PolarStereographic::PolarStereographic(), GeographicLib::LambertConformalConic::Reverse(), GeographicLib::PolarStereographic::SetScale(), GeographicLib::AlbersEqualArea::SetScale(), GeographicLib::LambertConformalConic::SetScale(), GeographicLib::TransverseMercator::TransverseMercator(), and GeographicLib::TransverseMercatorExact::TransverseMercatorExact().
|
inlinestatic |
|
inlinestatic |
A synonym for NaN<real>().
|
inlinestatic |
Test for NaN.
T | the type of the argument. |
[in] | x |
Definition at line 486 of file Math.hpp.
Referenced by GeographicLib::Geohash::Forward(), GeographicLib::MGRS::Forward(), GeographicLib::GeoCoords::GeoRepresentation(), main(), GeographicLib::UTMUPS::Reverse(), and GeographicLib::UTMUPS::StandardZone().
|
inlinestatic |
|
inlinestatic |
A synonym for infinity<real>().
|
inlinestatic |
|
static |
Number of additional decimal digits of precision of real relative to double (0 for float).
Definition at line 113 of file Math.hpp.
Referenced by GeographicLib::GeoCoords::DMSRepresentation(), GeographicLib::DMS::Encode(), GeographicLib::GeoCoords::GeoRepresentation(), and main().
|
static |
true if the machine is big-endian.
Definition at line 122 of file Math.hpp.
Referenced by GeographicLib::Utility::readarray(), and GeographicLib::Utility::writearray().