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
48# if GEOGRAPHICLIB_PRECISION > 5
49# define MPREAL_FIXED_PRECISION GEOGRAPHICLIB_PRECISION
51# define MPREAL_FIXED_PRECISION 0
56#if GEOGRAPHICLIB_PRECISION > 3
58# define GEOGRAPHICLIB_VOLATILE
61# define GEOGRAPHICLIB_PANIC(msg) \
62 (throw GeographicLib::GeographicErr(msg), false)
64# define GEOGRAPHICLIB_VOLATILE volatile
67# define GEOGRAPHICLIB_PANIC(msg) false
88#if GEOGRAPHICLIB_HAVE_LONG_DOUBLE
98#if GEOGRAPHICLIB_PRECISION == 2
106#elif GEOGRAPHICLIB_PRECISION == 1
108#elif GEOGRAPHICLIB_PRECISION == 3
110#elif GEOGRAPHICLIB_PRECISION == 4
111 typedef boost::multiprecision::float128
real;
112#elif GEOGRAPHICLIB_PRECISION >= 5
113 typedef mpfr::mpreal
real;
142#if __cplusplus >= 201703L
143 static inline constexpr int qd = 90;
144 static inline constexpr int dm = 60;
145 static inline constexpr int ms = 60;
146 static inline constexpr int hd = 2 * qd;
147 static inline constexpr int td = 2 * hd;
148 static inline constexpr int ds = dm * ms;
149#elif GEOGRAPHICLIB_PRECISION < 4
150 static constexpr int qd = 90;
151 static constexpr int dm = 60;
152 static constexpr int ms = 60;
153 static constexpr int hd = 2 * qd;
154 static constexpr int td = 2 * hd;
155 static constexpr int ds = dm * ms;
183 static int set_digits(
int ndigits);
188 static int digits10();
194 static int extra_digits();
205 template<
typename T = real>
static T
pi() {
207 static const T pi = atan2(T(0), T(-1));
215 template<
typename T = real>
static T
degree() {
216 static const T degree = pi<T>() / T(hd);
227 template<
typename T>
static T
sq(T x)
237 template<
typename T>
static void norm(T& x, T& y) {
238#if defined(_MSC_VER) && defined(_M_IX86)
249 using std::sqrt; T h = sqrt(x * x + y * y);
251 using std::hypot; T h = hypot(x, y);
269 template<
typename T>
static T sum(T u, T v, T& t);
286 template<
typename T>
static T
polyval(
int N,
const T p[], T x) {
290 T y = N < 0 ? 0 : *p++;
291 while (--N >= 0) y = y * x + *p++;
305 template<
typename T>
static T AngNormalize(T x);
315 template<
typename T>
static T
LatFix(T x)
316 {
using std::fabs;
return fabs(x) > T(qd) ? NaN<T>() : x; }
335 template<
typename T>
static T AngDiff(T x, T y, T& e);
349 template<
typename T>
static T
AngDiff(T x, T y)
350 { T e;
return AngDiff(x, y, e); }
366 template<
typename T>
static T AngRound(T x);
381 template<
typename T>
static void sincosd(T x, T& sinx, T& cosx);
398 template<
typename T>
static void sincosde(T x, T t, T& sinx, T& cosx);
410 template<
typename T>
static T sind(T x);
421 template<
typename T>
static T cosd(T x);
433 template<
typename T>
static T tand(T x);
446 template<
typename T>
static T atan2d(T y, T x);
455 template<
typename T>
static T atand(T x);
469 template<
typename T>
static T eatanhe(T x, T es);
488 template<
typename T>
static T taupf(T tau, T es);
507 template<
typename T>
static T tauf(T taup, T es);
519 template<
typename T>
static T hypot3(T x, T y, T z);
527 template<
typename T = real>
static T NaN();
535 template<
typename T = real>
static T infinity();
544 template<
typename T>
static T
swab(T x) {
547 unsigned char c[
sizeof(T)];
550 for (
int i =
sizeof(T)/2; i--; )
551 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.
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)