| 1 | #cxx . . $ `<file>/melder/NUMmath.h`/ifndef _NUMmath_h_ |
| 2 | #define _NUMmath_h_cxx . . $ `melder/NUMmath.h:2:9`! |
| 3 | /* NUMmath.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2018 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /* More mathematical and numerical things than there are in <math.h>. */ |
| 22 | |
| 23 | /********** Inherit all the ANSI functions from math.h **********/ |
| 24 | |
| 25 | /* On the sgi, math.h declares some bessel functions. */ |
| 26 | /* The following statements suppress these declarations */ |
| 27 | /* so that the compiler will issue no warnings */ |
| 28 | /* when you redeclare y0 etc. in your code. */ |
| 29 | #ifdef sgi |
| 30 | #define y0 sgi_y0 |
| 31 | #define y1 sgi_y1 |
| 32 | #define yn sgi_yn |
| 33 | #define j0 sgi_j0 |
| 34 | #define j1 sgi_j1 |
| 35 | #define jn sgi_jn |
| 36 | #endif |
| 37 | #include <math.h> |
| 38 | #ifdef sgi |
| 39 | #undef y0 |
| 40 | #undef y1 |
| 41 | #undef yn |
| 42 | #undef j0 |
| 43 | #undef j1 |
| 44 | #undef jn |
| 45 | #endif |
| 46 | |
| 47 | #undef M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! /* M_PI is a GNU extension, so not always available under -std=c++17 (one can also use NUMpi) */ |
| 48 | #define M_PIcxx . . $ `melder/NUMmath.h:48:9`! 3.1415926535897932384626433832795028841972 |
| 49 | |
| 50 | void NUMshiftcxx . . $ NUMshift(5d4b701516ac998a). (double *x, double xfrom, double xto); |
| 51 | void NUMscalecxx . . $ NUMscale(7a063e507c827c33). (double *x, double xminfrom, double xmaxfrom, double xminto, double xmaxto); |
| 52 | |
| 53 | /********** Constants ********** |
| 54 | * Forty-digit constants computed by e.g.: |
| 55 | * bc -l |
| 56 | * scale=42 |
| 57 | * print e(1) |
| 58 | * Then rounding away the last two digits. |
| 59 | */ |
| 60 | // print e(1) |
| 61 | constexpr double NUMecxx . . $ NUMe. = 2.7182818284590452353602874713526624977572; |
| 62 | // print 1/l(2) |
| 63 | constexpr double NUMlog2ecxx . . $ NUMlog2e. = 1.4426950408889634073599246810018921374266; |
| 64 | // print l(10)/l(2) |
| 65 | constexpr double NUMlog2_10cxx . . $ NUMlog2_10. = 3.3219280948873623478703194294893901758648; |
| 66 | // print 1/l(10) |
| 67 | constexpr double NUMlog10ecxx . . $ NUMlog10e. = 0.4342944819032518276511289189166050822944; |
| 68 | // print l(2)/l(10) |
| 69 | constexpr double NUMlog10_2cxx . . $ NUMlog10_2. = 0.3010299956639811952137388947244930267682; |
| 70 | // print l(2) |
| 71 | constexpr double NUMln2cxx . . $ NUMln2. = 0.6931471805599453094172321214581765680755; |
| 72 | // print l(10) |
| 73 | constexpr double NUMln10cxx . . $ NUMln10. = 2.3025850929940456840179914546843642076011; |
| 74 | // print a(1)*8 |
| 75 | constexpr double NUM2picxx . . $ NUM2pi. = 6.2831853071795864769252867665590057683943; |
| 76 | // print a(1)*4 |
| 77 | constexpr double NUMpicxx . . $ NUMpi. = 3.1415926535897932384626433832795028841972; |
| 78 | // print a(1)*2 |
| 79 | constexpr double NUMpi_2cxx . . $ NUMpi_2. = 1.5707963267948966192313216916397514420986; |
| 80 | // print a(1) |
| 81 | constexpr double NUMpi_4cxx . . $ NUMpi_4. = 0.7853981633974483096156608458198757210493; |
| 82 | // print 0.25/a(1) |
| 83 | constexpr double NUM1_picxx . . $ NUM1_pi. = 0.3183098861837906715377675267450287240689; |
| 84 | // print 0.5/a(1) |
| 85 | constexpr double NUM2_picxx . . $ NUM2_pi. = 0.6366197723675813430755350534900574481378; |
| 86 | // print sqrt(a(1)*4) |
| 87 | constexpr double NUMsqrtpicxx . . $ NUMsqrtpi. = 1.7724538509055160272981674833411451827975; |
| 88 | // print sqrt(a(1)*8) |
| 89 | constexpr double NUMsqrt2picxx . . $ NUMsqrt2pi. = 2.5066282746310005024157652848110452530070; |
| 90 | // print 1/sqrt(a(1)*8) |
| 91 | constexpr double NUM1_sqrt2picxx . . $ NUM1_sqrt2pi. = 0.3989422804014326779399460599343818684759; |
| 92 | // print 1/sqrt(a(1)) |
| 93 | constexpr double NUM2_sqrtpicxx . . $ NUM2_sqrtpi. = 1.1283791670955125738961589031215451716881; |
| 94 | // print l(a(1)*4) |
| 95 | constexpr double NUMlnpicxx . . $ NUMlnpi. = 1.1447298858494001741434273513530587116473; |
| 96 | // print sqrt(2) |
| 97 | constexpr double NUMsqrt2cxx . . $ NUMsqrt2. = 1.4142135623730950488016887242096980785697; |
| 98 | // print sqrt(0.5) |
| 99 | constexpr double NUMsqrt1_2cxx . . $ NUMsqrt1_2. = 0.7071067811865475244008443621048490392848; |
| 100 | // print sqrt(3) |
| 101 | constexpr double NUMsqrt3cxx . . $ NUMsqrt3. = 1.7320508075688772935274463415058723669428; |
| 102 | // print sqrt(5) |
| 103 | constexpr double NUMsqrt5cxx . . $ NUMsqrt5. = 2.2360679774997896964091736687312762354406; |
| 104 | // print sqrt(6) |
| 105 | constexpr double NUMsqrt6cxx . . $ NUMsqrt6. = 2.4494897427831780981972840747058913919659; |
| 106 | // print sqrt(7) |
| 107 | constexpr double NUMsqrt7cxx . . $ NUMsqrt7. = 2.6457513110645905905016157536392604257102; |
| 108 | // print sqrt(8) |
| 109 | constexpr double NUMsqrt8cxx . . $ NUMsqrt8. = 2.8284271247461900976033774484193961571393; |
| 110 | // print sqrt(10) |
| 111 | constexpr double NUMsqrt10cxx . . $ NUMsqrt10. = 3.1622776601683793319988935444327185337196; |
| 112 | // print sqrt(5)/2-0.5 |
| 113 | constexpr double NUM_goldenSectioncxx . . $ NUM_goldenSection. = 0.6180339887498948482045868343656381177203; |
| 114 | // The Euler-Mascheroni constant cannot be computed by bc. |
| 115 | // Instead we use the 40 digits computed by Johann von Soldner in 1809. |
| 116 | constexpr double NUM_eulercxx . . $ NUM_euler. = 0.5772156649015328606065120900824024310422; |
| 117 | |
| 118 | /* End of file NUMmath.h */ |
| 119 | #endif |