GeographicLib  1.50
Math.hpp
Go to the documentation of this file.
1 /**
2  * \file Math.hpp
3  * \brief Header for GeographicLib::Math class
4  *
5  * Copyright (c) Charles Karney (2008-2019) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * https://geographiclib.sourceforge.io/
8  **********************************************************************/
9 
10 // Constants.hpp includes Math.hpp. Place this include outside Math.hpp's
11 // include guard to enforce this ordering.
13 
14 #if !defined(GEOGRAPHICLIB_MATH_HPP)
15 #define GEOGRAPHICLIB_MATH_HPP 1
16 
17 /**
18  * Are C++11 math functions available?
19  **********************************************************************/
20 #if !defined(GEOGRAPHICLIB_CXX11_MATH)
21 // Recent versions of g++ -std=c++11 (4.7 and later?) set __cplusplus to 201103
22 // and support the new C++11 mathematical functions, std::atanh, etc. However
23 // the Android toolchain, which uses g++ -std=c++11 (4.8 as of 2014-03-11,
24 // according to Pullan Lu), does not support std::atanh. Android toolchains
25 // might define __ANDROID__ or ANDROID; so need to check both. With OSX the
26 // version is GNUC version 4.2 and __cplusplus is set to 201103, so remove the
27 // version check on GNUC.
28 # if defined(__GNUC__) && __cplusplus >= 201103 && \
29  !(defined(__ANDROID__) || defined(ANDROID) || defined(__CYGWIN__))
30 # define GEOGRAPHICLIB_CXX11_MATH 1
31 // Visual C++ 12 supports these functions
32 # elif defined(_MSC_VER) && _MSC_VER >= 1800
33 # define GEOGRAPHICLIB_CXX11_MATH 1
34 # else
35 # define GEOGRAPHICLIB_CXX11_MATH 0
36 # endif
37 #endif
38 
39 #if !defined(GEOGRAPHICLIB_WORDS_BIGENDIAN)
40 # define GEOGRAPHICLIB_WORDS_BIGENDIAN 0
41 #endif
42 
43 #if !defined(GEOGRAPHICLIB_HAVE_LONG_DOUBLE)
44 # define GEOGRAPHICLIB_HAVE_LONG_DOUBLE 0
45 #endif
46 
47 #if !defined(GEOGRAPHICLIB_PRECISION)
48 /**
49  * The precision of floating point numbers used in %GeographicLib. 1 means
50  * float (single precision); 2 (the default) means double; 3 means long double;
51  * 4 is reserved for quadruple precision. Nearly all the testing has been
52  * carried out with doubles and that's the recommended configuration. In order
53  * for long double to be used, GEOGRAPHICLIB_HAVE_LONG_DOUBLE needs to be
54  * defined. Note that with Microsoft Visual Studio, long double is the same as
55  * double.
56  **********************************************************************/
57 # define GEOGRAPHICLIB_PRECISION 2
58 #endif
59 
60 #include <cmath>
61 #include <algorithm>
62 #include <limits>
63 
64 #if GEOGRAPHICLIB_PRECISION == 4
65 #include <boost/version.hpp>
66 #include <boost/multiprecision/float128.hpp>
67 #include <boost/math/special_functions.hpp>
68 #elif GEOGRAPHICLIB_PRECISION == 5
69 #include <mpreal.h>
70 #endif
71 
72 #if GEOGRAPHICLIB_PRECISION > 3
73 // volatile keyword makes no sense for multiprec types
74 #define GEOGRAPHICLIB_VOLATILE
75 // Signal a convergence failure with multiprec types by throwing an exception
76 // at loop exit.
77 #define GEOGRAPHICLIB_PANIC \
78  (throw GeographicLib::GeographicErr("Convergence failure"), false)
79 #else
80 #define GEOGRAPHICLIB_VOLATILE volatile
81 // Ignore convergence failures with standard floating points types by allowing
82 // loop to exit cleanly.
83 #define GEOGRAPHICLIB_PANIC false
84 #endif
85 
86 namespace GeographicLib {
87 
88  /**
89  * \brief Mathematical functions needed by %GeographicLib
90  *
91  * Define mathematical functions in order to localize system dependencies and
92  * to provide generic versions of the functions. In addition define a real
93  * type to be used by %GeographicLib.
94  *
95  * Example of use:
96  * \include example-Math.cpp
97  **********************************************************************/
99  private:
100  void dummy(); // Static check for GEOGRAPHICLIB_PRECISION
101  Math(); // Disable constructor
102  public:
103 
104 #if GEOGRAPHICLIB_HAVE_LONG_DOUBLE
105  /**
106  * The extended precision type for real numbers, used for some testing.
107  * This is long double on computers with this type; otherwise it is double.
108  **********************************************************************/
109  typedef long double extended;
110 #else
111  typedef double extended;
112 #endif
113 
114 #if GEOGRAPHICLIB_PRECISION == 2
115  /**
116  * The real type for %GeographicLib. Nearly all the testing has been done
117  * with \e real = double. However, the algorithms should also work with
118  * float and long double (where available). (<b>CAUTION</b>: reasonable
119  * accuracy typically cannot be obtained using floats.)
120  **********************************************************************/
121  typedef double real;
122 #elif GEOGRAPHICLIB_PRECISION == 1
123  typedef float real;
124 #elif GEOGRAPHICLIB_PRECISION == 3
125  typedef extended real;
126 #elif GEOGRAPHICLIB_PRECISION == 4
127  typedef boost::multiprecision::float128 real;
128 #elif GEOGRAPHICLIB_PRECISION == 5
129  typedef mpfr::mpreal real;
130 #else
131  typedef double real;
132 #endif
133 
134  /**
135  * @return the number of bits of precision in a real number.
136  **********************************************************************/
137  static int digits();
138 
139  /**
140  * Set the binary precision of a real number.
141  *
142  * @param[in] ndigits the number of bits of precision.
143  * @return the resulting number of bits of precision.
144  *
145  * This only has an effect when GEOGRAPHICLIB_PRECISION = 5. See also
146  * Utility::set_digits for caveats about when this routine should be
147  * called.
148  **********************************************************************/
149  static int set_digits(int ndigits);
150 
151  /**
152  * @return the number of decimal digits of precision in a real number.
153  **********************************************************************/
154  static int digits10();
155 
156  /**
157  * Number of additional decimal digits of precision for real relative to
158  * double (0 for float).
159  **********************************************************************/
160  static int extra_digits();
161 
162  /**
163  * true if the machine is big-endian.
164  **********************************************************************/
165  static const bool bigendian = GEOGRAPHICLIB_WORDS_BIGENDIAN;
166 
167  /**
168  * @tparam T the type of the returned value.
169  * @return &pi;.
170  **********************************************************************/
171  template<typename T> static T pi() {
172  using std::atan2;
173  static const T pi = atan2(T(0), T(-1));
174  return pi;
175  }
176  /**
177  * A synonym for pi<real>().
178  **********************************************************************/
179  static real pi() { return pi<real>(); }
180 
181  /**
182  * @tparam T the type of the returned value.
183  * @return the number of radians in a degree.
184  **********************************************************************/
185  template<typename T> static T degree() {
186  static const T degree = pi<T>() / 180;
187  return degree;
188  }
189  /**
190  * A synonym for degree<real>().
191  **********************************************************************/
192  static real degree() { return degree<real>(); }
193 
194  /**
195  * Square a number.
196  *
197  * @tparam T the type of the argument and the returned value.
198  * @param[in] x
199  * @return <i>x</i><sup>2</sup>.
200  **********************************************************************/
201  template<typename T> static T sq(T x)
202  { return x * x; }
203 
204  /**
205  * The hypotenuse function avoiding underflow and overflow.
206  *
207  * @tparam T the type of the arguments and the returned value.
208  * @param[in] x
209  * @param[in] y
210  * @return sqrt(<i>x</i><sup>2</sup> + <i>y</i><sup>2</sup>).
211  **********************************************************************/
212  template<typename T> static T hypot(T x, T y);
213 
214  /**
215  * exp(\e x) &minus; 1 accurate near \e x = 0.
216  *
217  * @tparam T the type of the argument and the returned value.
218  * @param[in] x
219  * @return exp(\e x) &minus; 1.
220  **********************************************************************/
221  template<typename T> static T expm1(T x);
222 
223  /**
224  * log(1 + \e x) accurate near \e x = 0.
225  *
226  * @tparam T the type of the argument and the returned value.
227  * @param[in] x
228  * @return log(1 + \e x).
229  **********************************************************************/
230  template<typename T> static T log1p(T x);
231 
232  /**
233  * The inverse hyperbolic sine function.
234  *
235  * @tparam T the type of the argument and the returned value.
236  * @param[in] x
237  * @return asinh(\e x).
238  **********************************************************************/
239  template<typename T> static T asinh(T x);
240 
241  /**
242  * The inverse hyperbolic tangent function.
243  *
244  * @tparam T the type of the argument and the returned value.
245  * @param[in] x
246  * @return atanh(\e x).
247  **********************************************************************/
248  template<typename T> static T atanh(T x);
249 
250  /**
251  * Copy the sign.
252  *
253  * @tparam T the type of the argument.
254  * @param[in] x gives the magitude of the result.
255  * @param[in] y gives the sign of the result.
256  * @return value with the magnitude of \e x and with the sign of \e y.
257  *
258  * This routine correctly handles the case \e y = &minus;0, returning
259  * &minus|<i>x</i>|.
260  **********************************************************************/
261  template<typename T> static T copysign(T x, T y);
262 
263  /**
264  * The cube root function.
265  *
266  * @tparam T the type of the argument and the returned value.
267  * @param[in] x
268  * @return the real cube root of \e x.
269  **********************************************************************/
270  template<typename T> static T cbrt(T x);
271 
272  /**
273  * The remainder function.
274  *
275  * @tparam T the type of the arguments and the returned value.
276  * @param[in] x
277  * @param[in] y
278  * @return the remainder of \e x/\e y in the range [&minus;\e y/2, \e y/2].
279  **********************************************************************/
280  template<typename T> static T remainder(T x, T y);
281 
282  /**
283  * The remquo function.
284  *
285  * @tparam T the type of the arguments and the returned value.
286  * @param[in] x
287  * @param[in] y
288  * @param[out] n the low 3 bits of the quotient
289  * @return the remainder of \e x/\e y in the range [&minus;\e y/2, \e y/2].
290  **********************************************************************/
291  template<typename T> static T remquo(T x, T y, int* n);
292 
293  /**
294  * The round function.
295  *
296  * @tparam T the type of the argument and the returned value.
297  * @param[in] x
298  * @return \e x round to the nearest integer (ties round away from 0).
299  **********************************************************************/
300  template<typename T> static T round(T x);
301 
302  /**
303  * The lround function.
304  *
305  * @tparam T the type of the argument.
306  * @param[in] x
307  * @return \e x round to the nearest integer as a long int (ties round away
308  * from 0).
309  *
310  * If the result does not fit in a long int, the return value is undefined.
311  **********************************************************************/
312  template<typename T> static long lround(T x);
313 
314  /**
315  * Fused multiply and add.
316  *
317  * @tparam T the type of the arguments and the returned value.
318  * @param[in] x
319  * @param[in] y
320  * @param[in] z
321  * @return <i>xy</i> + <i>z</i>, correctly rounded (on those platforms with
322  * support for the <code>fma</code> instruction).
323  *
324  * On platforms without the <code>fma</code> instruction, no attempt is
325  * made to improve on the result of a rounded multiplication followed by a
326  * rounded addition.
327  **********************************************************************/
328  template<typename T> static T fma(T x, T y, T z);
329 
330  /**
331  * Normalize a two-vector.
332  *
333  * @tparam T the type of the argument and the returned value.
334  * @param[in,out] x on output set to <i>x</i>/hypot(<i>x</i>, <i>y</i>).
335  * @param[in,out] y on output set to <i>y</i>/hypot(<i>x</i>, <i>y</i>).
336  **********************************************************************/
337  template<typename T> static void norm(T& x, T& y)
338  { T h = hypot(x, y); x /= h; y /= h; }
339 
340  /**
341  * The error-free sum of two numbers.
342  *
343  * @tparam T the type of the argument and the returned value.
344  * @param[in] u
345  * @param[in] v
346  * @param[out] t the exact error given by (\e u + \e v) - \e s.
347  * @return \e s = round(\e u + \e v).
348  *
349  * See D. E. Knuth, TAOCP, Vol 2, 4.2.2, Theorem B. (Note that \e t can be
350  * the same as one of the first two arguments.)
351  **********************************************************************/
352  template<typename T> static T sum(T u, T v, T& t);
353 
354  /**
355  * Evaluate a polynomial.
356  *
357  * @tparam T the type of the arguments and returned value.
358  * @param[in] N the order of the polynomial.
359  * @param[in] p the coefficient array (of size \e N + 1).
360  * @param[in] x the variable.
361  * @return the value of the polynomial.
362  *
363  * Evaluate <i>y</i> = &sum;<sub><i>n</i>=0..<i>N</i></sub>
364  * <i>p</i><sub><i>n</i></sub> <i>x</i><sup><i>N</i>&minus;<i>n</i></sup>.
365  * Return 0 if \e N &lt; 0. Return <i>p</i><sub>0</sub>, if \e N = 0 (even
366  * if \e x is infinite or a nan). The evaluation uses Horner's method.
367  **********************************************************************/
368  template<typename T> static T polyval(int N, const T p[], T x)
369  // This used to employ Math::fma; but that's too slow and it seemed not to
370  // improve the accuracy noticeably. This might change when there's direct
371  // hardware support for fma.
372  { T y = N < 0 ? 0 : *p++; while (--N >= 0) y = y * x + *p++; return y; }
373 
374  /**
375  * Normalize an angle.
376  *
377  * @tparam T the type of the argument and returned value.
378  * @param[in] x the angle in degrees.
379  * @return the angle reduced to the range (&minus;180&deg;, 180&deg;].
380  *
381  * The range of \e x is unrestricted.
382  **********************************************************************/
383  template<typename T> static T AngNormalize(T x) {
384  x = remainder(x, T(360)); return x != -180 ? x : 180;
385  }
386 
387  /**
388  * Normalize a latitude.
389  *
390  * @tparam T the type of the argument and returned value.
391  * @param[in] x the angle in degrees.
392  * @return x if it is in the range [&minus;90&deg;, 90&deg;], otherwise
393  * return NaN.
394  **********************************************************************/
395  template<typename T> static T LatFix(T x)
396  { using std::abs; return abs(x) > 90 ? NaN<T>() : x; }
397 
398  /**
399  * The exact difference of two angles reduced to
400  * (&minus;180&deg;, 180&deg;].
401  *
402  * @tparam T the type of the arguments and returned value.
403  * @param[in] x the first angle in degrees.
404  * @param[in] y the second angle in degrees.
405  * @param[out] e the error term in degrees.
406  * @return \e d, the truncated value of \e y &minus; \e x.
407  *
408  * This computes \e z = \e y &minus; \e x exactly, reduced to
409  * (&minus;180&deg;, 180&deg;]; and then sets \e z = \e d + \e e where \e d
410  * is the nearest representable number to \e z and \e e is the truncation
411  * error. If \e d = &minus;180, then \e e &gt; 0; If \e d = 180, then \e e
412  * &le; 0.
413  **********************************************************************/
414  template<typename T> static T AngDiff(T x, T y, T& e) {
415  T t, d = AngNormalize(sum(remainder(-x, T(360)),
416  remainder( y, T(360)), t));
417  // Here y - x = d + t (mod 360), exactly, where d is in (-180,180] and
418  // abs(t) <= eps (eps = 2^-45 for doubles). The only case where the
419  // addition of t takes the result outside the range (-180,180] is d = 180
420  // and t > 0. The case, d = -180 + eps, t = -eps, can't happen, since
421  // sum would have returned the exact result in such a case (i.e., given t
422  // = 0).
423  return sum(d == 180 && t > 0 ? -180 : d, t, e);
424  }
425 
426  /**
427  * Difference of two angles reduced to [&minus;180&deg;, 180&deg;]
428  *
429  * @tparam T the type of the arguments and returned value.
430  * @param[in] x the first angle in degrees.
431  * @param[in] y the second angle in degrees.
432  * @return \e y &minus; \e x, reduced to the range [&minus;180&deg;,
433  * 180&deg;].
434  *
435  * The result is equivalent to computing the difference exactly, reducing
436  * it to (&minus;180&deg;, 180&deg;] and rounding the result. Note that
437  * this prescription allows &minus;180&deg; to be returned (e.g., if \e x
438  * is tiny and negative and \e y = 180&deg;).
439  **********************************************************************/
440  template<typename T> static T AngDiff(T x, T y)
441  { T e; return AngDiff(x, y, e); }
442 
443  /**
444  * Coarsen a value close to zero.
445  *
446  * @tparam T the type of the argument and returned value.
447  * @param[in] x
448  * @return the coarsened value.
449  *
450  * The makes the smallest gap in \e x = 1/16 &minus; nextafter(1/16, 0) =
451  * 1/2<sup>57</sup> for reals = 0.7 pm on the earth if \e x is an angle in
452  * degrees. (This is about 1000 times more resolution than we get with
453  * angles around 90&deg;.) We use this to avoid having to deal with near
454  * singular cases when \e x is non-zero but tiny (e.g.,
455  * 10<sup>&minus;200</sup>). This converts &minus;0 to +0; however tiny
456  * negative numbers get converted to &minus;0.
457  **********************************************************************/
458  template<typename T> static T AngRound(T x);
459 
460  /**
461  * Evaluate the sine and cosine function with the argument in degrees
462  *
463  * @tparam T the type of the arguments.
464  * @param[in] x in degrees.
465  * @param[out] sinx sin(<i>x</i>).
466  * @param[out] cosx cos(<i>x</i>).
467  *
468  * The results obey exactly the elementary properties of the trigonometric
469  * functions, e.g., sin 9&deg; = cos 81&deg; = &minus; sin 123456789&deg;.
470  * If x = &minus;0, then \e sinx = &minus;0; this is the only case where
471  * &minus;0 is returned.
472  **********************************************************************/
473  template<typename T> static void sincosd(T x, T& sinx, T& cosx);
474 
475  /**
476  * Evaluate the sine function with the argument in degrees
477  *
478  * @tparam T the type of the argument and the returned value.
479  * @param[in] x in degrees.
480  * @return sin(<i>x</i>).
481  **********************************************************************/
482  template<typename T> static T sind(T x);
483 
484  /**
485  * Evaluate the cosine function with the argument in degrees
486  *
487  * @tparam T the type of the argument and the returned value.
488  * @param[in] x in degrees.
489  * @return cos(<i>x</i>).
490  **********************************************************************/
491  template<typename T> static T cosd(T x);
492 
493  /**
494  * Evaluate the tangent function with the argument in degrees
495  *
496  * @tparam T the type of the argument and the returned value.
497  * @param[in] x in degrees.
498  * @return tan(<i>x</i>).
499  *
500  * If \e x = &plusmn;90&deg;, then a suitably large (but finite) value is
501  * returned.
502  **********************************************************************/
503  template<typename T> static T tand(T x);
504 
505  /**
506  * Evaluate the atan2 function with the result in degrees
507  *
508  * @tparam T the type of the arguments and the returned value.
509  * @param[in] y
510  * @param[in] x
511  * @return atan2(<i>y</i>, <i>x</i>) in degrees.
512  *
513  * The result is in the range (&minus;180&deg; 180&deg;]. N.B.,
514  * atan2d(&plusmn;0, &minus;1) = +180&deg;; atan2d(&minus;&epsilon;,
515  * &minus;1) = &minus;180&deg;, for &epsilon; positive and tiny;
516  * atan2d(&plusmn;0, +1) = &plusmn;0&deg;.
517  **********************************************************************/
518  template<typename T> static T atan2d(T y, T x);
519 
520  /**
521  * Evaluate the atan function with the result in degrees
522  *
523  * @tparam T the type of the argument and the returned value.
524  * @param[in] x
525  * @return atan(<i>x</i>) in degrees.
526  **********************************************************************/
527  template<typename T> static T atand(T x);
528 
529  /**
530  * Evaluate <i>e</i> atanh(<i>e x</i>)
531  *
532  * @tparam T the type of the argument and the returned value.
533  * @param[in] x
534  * @param[in] es the signed eccentricity = sign(<i>e</i><sup>2</sup>)
535  * sqrt(|<i>e</i><sup>2</sup>|)
536  * @return <i>e</i> atanh(<i>e x</i>)
537  *
538  * If <i>e</i><sup>2</sup> is negative (<i>e</i> is imaginary), the
539  * expression is evaluated in terms of atan.
540  **********************************************************************/
541  template<typename T> static T eatanhe(T x, T es);
542 
543  /**
544  * tan&chi; in terms of tan&phi;
545  *
546  * @tparam T the type of the argument and the returned value.
547  * @param[in] tau &tau; = tan&phi;
548  * @param[in] es the signed eccentricity = sign(<i>e</i><sup>2</sup>)
549  * sqrt(|<i>e</i><sup>2</sup>|)
550  * @return &tau;&prime; = tan&chi;
551  *
552  * See Eqs. (7--9) of
553  * C. F. F. Karney,
554  * <a href="https://doi.org/10.1007/s00190-011-0445-3">
555  * Transverse Mercator with an accuracy of a few nanometers,</a>
556  * J. Geodesy 85(8), 475--485 (Aug. 2011)
557  * (preprint
558  * <a href="https://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>).
559  **********************************************************************/
560  template<typename T> static T taupf(T tau, T es);
561 
562  /**
563  * tan&phi; in terms of tan&chi;
564  *
565  * @tparam T the type of the argument and the returned value.
566  * @param[in] taup &tau;&prime; = tan&chi;
567  * @param[in] es the signed eccentricity = sign(<i>e</i><sup>2</sup>)
568  * sqrt(|<i>e</i><sup>2</sup>|)
569  * @return &tau; = tan&phi;
570  *
571  * See Eqs. (19--21) of
572  * C. F. F. Karney,
573  * <a href="https://doi.org/10.1007/s00190-011-0445-3">
574  * Transverse Mercator with an accuracy of a few nanometers,</a>
575  * J. Geodesy 85(8), 475--485 (Aug. 2011)
576  * (preprint
577  * <a href="https://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>).
578  **********************************************************************/
579  template<typename T> static T tauf(T taup, T es);
580 
581  /**
582  * Test for finiteness.
583  *
584  * @tparam T the type of the argument.
585  * @param[in] x
586  * @return true if number is finite, false if NaN or infinite.
587  **********************************************************************/
588  template<typename T> static bool isfinite(T x);
589 
590  /**
591  * The NaN (not a number)
592  *
593  * @tparam T the type of the returned value.
594  * @return NaN if available, otherwise return the max real of type T.
595  **********************************************************************/
596  template<typename T> static T NaN();
597 
598  /**
599  * A synonym for NaN<real>().
600  **********************************************************************/
601  static real NaN() { return NaN<real>(); }
602 
603  /**
604  * Test for NaN.
605  *
606  * @tparam T the type of the argument.
607  * @param[in] x
608  * @return true if argument is a NaN.
609  **********************************************************************/
610  template<typename T> static bool isnan(T x);
611 
612  /**
613  * Infinity
614  *
615  * @tparam T the type of the returned value.
616  * @return infinity if available, otherwise return the max real.
617  **********************************************************************/
618  template<typename T> static T infinity();
619 
620  /**
621  * A synonym for infinity<real>().
622  **********************************************************************/
623  static real infinity() { return infinity<real>(); }
624 
625  /**
626  * Swap the bytes of a quantity
627  *
628  * @tparam T the type of the argument and the returned value.
629  * @param[in] x
630  * @return x with its bytes swapped.
631  **********************************************************************/
632  template<typename T> static T swab(T x) {
633  union {
634  T r;
635  unsigned char c[sizeof(T)];
636  } b;
637  b.r = x;
638  for (int i = sizeof(T)/2; i--; )
639  std::swap(b.c[i], b.c[sizeof(T) - 1 - i]);
640  return b.r;
641  }
642 
643  };
644 
645 } // namespace GeographicLib
646 
647 #endif // GEOGRAPHICLIB_MATH_HPP
static T AngNormalize(T x)
Definition: Math.hpp:383
static T pi()
Definition: Math.hpp:171
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:92
#define GEOGRAPHICLIB_WORDS_BIGENDIAN
Definition: Math.hpp:40
static real degree()
Definition: Math.hpp:192
GeographicLib::Math::real real
Definition: GeodSolve.cpp:31
static T LatFix(T x)
Definition: Math.hpp:395
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:98
static T AngDiff(T x, T y, T &e)
Definition: Math.hpp:414
static void norm(T &x, T &y)
Definition: Math.hpp:337
static T sq(T x)
Definition: Math.hpp:201
static real pi()
Definition: Math.hpp:179
static T polyval(int N, const T p[], T x)
Definition: Math.hpp:368
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
static T degree()
Definition: Math.hpp:185
static T AngDiff(T x, T y)
Definition: Math.hpp:440
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
static real NaN()
Definition: Math.hpp:601
static T swab(T x)
Definition: Math.hpp:632
static real infinity()
Definition: Math.hpp:623
Header for GeographicLib::Constants class.