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;
136#if GEOGRAPHICLIB_PRECISION == 4
147#if GEOGRAPHICLIB_PRECISION == 4
168 static int set_digits(
int ndigits);
173 static int digits10();
179 static int extra_digits();
190 template<
typename T = real>
static T
pi() {
192 static const T pi = atan2(T(0), T(-1));
200 template<
typename T = real>
static T
degree() {
201 static const T degree = pi<T>() / T(hd);
212 template<
typename T>
static T
sq(T x)
222 template<
typename T>
static void norm(T& x, T& y) {
223#if defined(_MSC_VER) && defined(_M_IX86)
234 using std::sqrt; T h = sqrt(x * x + y * y);
236 using std::hypot; T h = hypot(x, y);
254 template<
typename T>
static T sum(T u, T v, T& t);
271 template<
typename T>
static T
polyval(
int N,
const T p[], T x) {
275 T y = N < 0 ? 0 : *p++;
276 while (--N >= 0) y = y * x + *p++;
290 template<
typename T>
static T AngNormalize(T x);
300 template<
typename T>
static T
LatFix(T x)
301 {
using std::fabs;
return fabs(x) > T(qd) ? NaN<T>() : x; }
320 template<
typename T>
static T AngDiff(T x, T y, T& e);
334 template<
typename T>
static T
AngDiff(T x, T y)
335 { T e;
return AngDiff(x, y, e); }
351 template<
typename T>
static T AngRound(T x);
366 template<
typename T>
static void sincosd(T x, T& sinx, T& cosx);
383 template<
typename T>
static void sincosde(T x, T t, T& sinx, T& cosx);
395 template<
typename T>
static T sind(T x);
406 template<
typename T>
static T cosd(T x);
418 template<
typename T>
static T tand(T x);
431 template<
typename T>
static T atan2d(T y, T x);
440 template<
typename T>
static T atand(T x);
454 template<
typename T>
static T eatanhe(T x, T es);
473 template<
typename T>
static T taupf(T tau, T es);
492 template<
typename T>
static T tauf(T taup, T es);
500 template<
typename T = real>
static T NaN();
508 template<
typename T = real>
static T infinity();
517 template<
typename T>
static T
swab(T x) {
520 unsigned char c[
sizeof(T)];
523 for (
int i =
sizeof(T)/2; i--; )
524 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)