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
44#include <boost/version.hpp>
45#include <boost/multiprecision/float128.hpp>
46#include <boost/math/special_functions.hpp>
47#elif GEOGRAPHICLIB_PRECISION == 5
51#if GEOGRAPHICLIB_PRECISION > 3
53#define GEOGRAPHICLIB_VOLATILE
56#define GEOGRAPHICLIB_PANIC(msg) \
57 (throw GeographicLib::GeographicErr(msg), false)
59#define GEOGRAPHICLIB_VOLATILE volatile
62#define GEOGRAPHICLIB_PANIC(msg) false
83#if GEOGRAPHICLIB_HAVE_LONG_DOUBLE
93#if GEOGRAPHICLIB_PRECISION == 2
101#elif GEOGRAPHICLIB_PRECISION == 1
103#elif GEOGRAPHICLIB_PRECISION == 3
105#elif GEOGRAPHICLIB_PRECISION == 4
106 typedef boost::multiprecision::float128
real;
107#elif GEOGRAPHICLIB_PRECISION == 5
108 typedef mpfr::mpreal
real;
137#if __cplusplus >= 201703L
138 static inline constexpr int qd = 90;
139 static inline constexpr int dm = 60;
140 static inline constexpr int ms = 60;
141 static inline constexpr int hd = 2 * qd;
142 static inline constexpr int td = 2 * hd;
143 static inline constexpr int ds = dm * ms;
144#elif GEOGRAPHICLIB_PRECISION < 4
145 static constexpr int qd = 90;
146 static constexpr int dm = 60;
147 static constexpr int ms = 60;
148 static constexpr int hd = 2 * qd;
149 static constexpr int td = 2 * hd;
150 static constexpr int ds = dm * ms;
177 static int set_digits(
int ndigits);
182 static int digits10();
188 static int extra_digits();
199 template<
typename T = real>
static T
pi() {
201 static const T pi = atan2(T(0), T(-1));
209 template<
typename T = real>
static T
degree() {
210 static const T degree = pi<T>() / T(hd);
221 template<
typename T>
static T
sq(T x)
231 template<
typename T>
static void norm(T& x, T& y) {
232#if defined(_MSC_VER) && defined(_M_IX86)
243 using std::sqrt; T h = sqrt(x * x + y * y);
245 using std::hypot; T h = hypot(x, y);
263 template<
typename T>
static T sum(T u, T v, T& t);
280 template<
typename T>
static T
polyval(
int N,
const T p[], T x) {
284 T y = N < 0 ? 0 : *p++;
285 while (--N >= 0) y = y * x + *p++;
299 template<
typename T>
static T AngNormalize(T x);
309 template<
typename T>
static T
LatFix(T x)
310 {
using std::fabs;
return fabs(x) > T(qd) ? NaN<T>() : x; }
329 template<
typename T>
static T AngDiff(T x, T y, T& e);
343 template<
typename T>
static T
AngDiff(T x, T y)
344 { T e;
return AngDiff(x, y, e); }
360 template<
typename T>
static T AngRound(T x);
375 template<
typename T>
static void sincosd(T x, T& sinx, T& cosx);
392 template<
typename T>
static void sincosde(T x, T t, T& sinx, T& cosx);
404 template<
typename T>
static T sind(T x);
415 template<
typename T>
static T cosd(T x);
427 template<
typename T>
static T tand(T x);
440 template<
typename T>
static T atan2d(T y, T x);
449 template<
typename T>
static T atand(T x);
463 template<
typename T>
static T eatanhe(T x, T es);
482 template<
typename T>
static T taupf(T tau, T es);
501 template<
typename T>
static T tauf(T taup, T es);
513 template<
typename T>
static T hypot3(T x, T y, T z);
521 template<
typename T = real>
static T NaN();
529 template<
typename T = real>
static T infinity();
538 template<
typename T>
static T
swab(T x) {
541 unsigned char c[
sizeof(T)];
544 for (
int i =
sizeof(T)/2; i--; )
545 std::swap(b.c[i], b.c[
sizeof(T) - 1 - i]);
Header for GeographicLib::Constants class.
#define GEOGRAPHICLIB_EXPORT
GeographicLib::Math::real real
#define GEOGRAPHICLIB_WORDS_BIGENDIAN
Mathematical functions needed by GeographicLib.
static void norm(T &x, T &y)
static T polyval(int N, const T p[], T x)
static T AngDiff(T x, T y)
Namespace for GeographicLib.