14#if !defined(GEOGRAPHICLIB_MATH_HPP)
15#define GEOGRAPHICLIB_MATH_HPP 1
17#if !defined(GEOGRAPHICLIB_WORDS_BIGENDIAN)
18# define GEOGRAPHICLIB_WORDS_BIGENDIAN 0
21#if !defined(GEOGRAPHICLIB_HAVE_LONG_DOUBLE)
22# define GEOGRAPHICLIB_HAVE_LONG_DOUBLE 0
25#if !defined(GEOGRAPHICLIB_PRECISION)
35# define GEOGRAPHICLIB_PRECISION 2
42#if GEOGRAPHICLIB_PRECISION == 4
43#include <boost/version.hpp>
44#include <boost/multiprecision/float128.hpp>
45#include <boost/math/special_functions.hpp>
46#elif GEOGRAPHICLIB_PRECISION == 5
50#if GEOGRAPHICLIB_PRECISION > 3
52#define GEOGRAPHICLIB_VOLATILE
55#define GEOGRAPHICLIB_PANIC \
56 (throw GeographicLib::GeographicErr("Convergence failure"), false)
58#define GEOGRAPHICLIB_VOLATILE volatile
61#define GEOGRAPHICLIB_PANIC false
82#if GEOGRAPHICLIB_HAVE_LONG_DOUBLE
92#if GEOGRAPHICLIB_PRECISION == 2
100#elif GEOGRAPHICLIB_PRECISION == 1
102#elif GEOGRAPHICLIB_PRECISION == 3
104#elif GEOGRAPHICLIB_PRECISION == 4
105 typedef boost::multiprecision::float128
real;
106#elif GEOGRAPHICLIB_PRECISION == 5
107 typedef mpfr::mpreal
real;
127 static int set_digits(
int ndigits);
132 static int digits10();
138 static int extra_digits();
149 template<
typename T = real>
static T
pi() {
151 static const T pi = atan2(T(0), T(-1));
159 template<
typename T = real>
static T
degree() {
160 static const T degree = pi<T>() / 180;
171 template<
typename T>
static T
sq(T x)
186 static T hypot(T x, T y);
255 static T copysign(T x, T y);
282 static T remainder(T x, T y);
297 static T remquo(T x, T y,
int* n);
326 static
long lround(T x);
346 static T fma(T x, T y, T z);
355 template<typename T> static
void norm(T& x, T& y) {
356#if defined(_MSC_VER) && defined(_M_IX86)
367 using std::sqrt; T h = sqrt(x * x + y * y);
369 using std::hypot; T h = hypot(x, y);
386 template<
typename T>
static T sum(T u, T v, T& t);
402 template<
typename T>
static T
polyval(
int N,
const T p[], T x) {
406 T y = N < 0 ? 0 : *p++;
407 while (--N >= 0) y = y * x + *p++;
421 using std::remainder;
422 x = remainder(x, T(360));
return x != -180 ? x : 180;
433 template<
typename T>
static T
LatFix(T x)
434 {
using std::abs;
return abs(x) > 90 ? NaN<T>() : x; }
452 template<
typename T>
static T
AngDiff(T x, T y, T& e) {
453 using std::remainder;
454 T t, d = AngNormalize(sum(remainder(-x, T(360)),
455 remainder( y, T(360)), t));
462 return sum(d == 180 && t > 0 ? -180 : d, t, e);
479 template<
typename T>
static T
AngDiff(T x, T y)
480 { T e;
return AngDiff(x, y, e); }
497 template<
typename T>
static T AngRound(T x);
512 template<
typename T>
static void sincosd(T x, T& sinx, T& cosx);
521 template<
typename T>
static T sind(T x);
530 template<
typename T>
static T cosd(T x);
542 template<
typename T>
static T tand(T x);
557 template<
typename T>
static T atan2d(T y, T x);
566 template<
typename T>
static T atand(T x);
580 template<
typename T>
static T eatanhe(T x, T es);
599 template<
typename T>
static T taupf(T tau, T es);
618 template<
typename T>
static T tauf(T taup, T es);
631 static
bool isfinite(T x);
639 template<typename T =
real> static T NaN();
652 static
bool isnan(T x);
660 template<typename T =
real> static T infinity();
669 template<typename T> static T swab(T x) {
672 unsigned char c[
sizeof(T)];
675 for (
int i =
sizeof(T)/2; i--; )
676 std::swap(b.c[i], b.c[
sizeof(T) - 1 - i]);
Header for GeographicLib::Constants class.
#define GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_DEPRECATED(msg)
GeographicLib::Math::real real
#define GEOGRAPHICLIB_WORDS_BIGENDIAN
Mathematical functions needed by GeographicLib.
static T AngNormalize(T x)
static T polyval(int N, const T p[], T x)
static T AngDiff(T x, T y)
static T AngDiff(T x, T y, T &e)
Namespace for GeographicLib.
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)