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 using std::hypot; T h = hypot(x, y); x /= h; y /= h;
371 template<
typename T>
static T sum(T u, T v, T& t);
387 template<
typename T>
static T
polyval(
int N,
const T p[], T x) {
391 T y = N < 0 ? 0 : *p++;
392 while (--N >= 0) y = y * x + *p++;
406 using std::remainder;
407 x = remainder(x, T(360));
return x != -180 ? x : 180;
418 template<
typename T>
static T
LatFix(T x)
419 {
using std::abs;
return abs(x) > 90 ? NaN<T>() : x; }
437 template<
typename T>
static T
AngDiff(T x, T y, T& e) {
438 using std::remainder;
439 T t, d = AngNormalize(sum(remainder(-x, T(360)),
440 remainder( y, T(360)), t));
447 return sum(d == 180 && t > 0 ? -180 : d, t, e);
464 template<
typename T>
static T
AngDiff(T x, T y)
465 { T e;
return AngDiff(x, y, e); }
482 template<
typename T>
static T AngRound(T x);
497 template<
typename T>
static void sincosd(T x, T& sinx, T& cosx);
506 template<
typename T>
static T sind(T x);
515 template<
typename T>
static T cosd(T x);
527 template<
typename T>
static T tand(T x);
542 template<
typename T>
static T atan2d(T y, T x);
551 template<
typename T>
static T atand(T x);
565 template<
typename T>
static T eatanhe(T x, T es);
584 template<
typename T>
static T taupf(T tau, T es);
603 template<
typename T>
static T tauf(T taup, T es);
616 static
bool isfinite(T x);
624 template<typename T =
real> static T NaN();
637 static
bool isnan(T x);
645 template<typename T =
real> static T infinity();
654 template<typename T> static T swab(T x) {
657 unsigned char c[
sizeof(T)];
660 for (
int i =
sizeof(T)/2; i--; )
661 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)