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>() / 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);
270 template<
typename T>
static T
polyval(
int N,
const T p[], T x) {
274 T y = N < 0 ? 0 : *p++;
275 while (--N >= 0) y = y * x + *p++;
289 template<
typename T>
static T AngNormalize(T x);
299 template<
typename T>
static T
LatFix(T x)
300 {
using std::fabs;
return fabs(x) > qd ? NaN<T>() : x; }
319 template<
typename T>
static T AngDiff(T x, T y, T& e);
333 template<
typename T>
static T
AngDiff(T x, T y)
334 { T e;
return AngDiff(x, y, e); }
350 template<
typename T>
static T AngRound(T x);
365 template<
typename T>
static void sincosd(T x, T& sinx, T& cosx);
382 template<
typename T>
static void sincosde(T x, T t, T& sinx, T& cosx);
394 template<
typename T>
static T sind(T x);
405 template<
typename T>
static T cosd(T x);
417 template<
typename T>
static T tand(T x);
430 template<
typename T>
static T atan2d(T y, T x);
439 template<
typename T>
static T atand(T x);
453 template<
typename T>
static T eatanhe(T x, T es);
472 template<
typename T>
static T taupf(T tau, T es);
491 template<
typename T>
static T tauf(T taup, T es);
499 template<
typename T = real>
static T NaN();
507 template<
typename T = real>
static T infinity();
516 template<
typename T>
static T
swab(T x) {
519 unsigned char c[
sizeof(T)];
522 for (
int i =
sizeof(T)/2; i--; )
523 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)