1 /////////////////////////////////////////////////////////////////////////// 2 // Inastemp - Berenger Bramas MPCDF - 2016 3 // Under MIT Licence, please you must read the LICENCE file. 4 /////////////////////////////////////////////////////////////////////////// 5 #ifndef INAFASTEXP_HPP 6 #define INAFASTEXP_HPP 7 8 #include <array> 9 #include <cmath> 10 11 /** 12 * This class provides the methods and constant to 13 * compute the fast exp functions. 14 * From the paper: Fast Exponential Computation on SIMD Architectures. 15 * The constant from Remez polynomials are generated 16 * with remez.sce (scilab) see documentation to know more. 17 */ 18 class InaFastExp { 19 static const long int S64 = (1L << 52); 20 static const long int S32 = (1L << 23); 21 22 public: CoeffLog2E()23 inline constexpr static double CoeffLog2E() { 24 // const double Euler = 2.71828182845904523536028747135266249775724709369995; 25 // return std::log2(Euler()); 26 return 1.442695040888963407359924681001892137426645954153; 27 } 28 CoeffA64()29 inline constexpr static double CoeffA64() { 30 return double(S64); 31 } 32 CoeffB64()33 inline constexpr static double CoeffB64() { 34 return double(S64 * 1023); 35 } 36 CoeffA32()37 inline constexpr static double CoeffA32() { 38 return double(S32); 39 } 40 CoeffB32()41 inline constexpr static double CoeffB32() { 42 return double(S32 * 127); 43 } 44 GetCoefficient3_0()45 inline constexpr static double GetCoefficient3_0() { 46 return -2.47142816509723700288e-03; 47 } GetCoefficient3_1()48 inline constexpr static double GetCoefficient3_1() { 49 return 3.48943001636461247461e-01; 50 } GetCoefficient3_2()51 inline constexpr static double GetCoefficient3_2() { 52 return -3.44000145306266491563e-01; 53 } 54 GetCoefficient4_0()55 inline constexpr static double GetCoefficient4_0() { 56 return 1.06906116358144185133e-04; 57 } GetCoefficient4_1()58 inline constexpr static double GetCoefficient4_1() { 59 return 3.03543677780836240743e-01; 60 } GetCoefficient4_2()61 inline constexpr static double GetCoefficient4_2() { 62 return -2.24339532327269441936e-01; 63 } GetCoefficient4_3()64 inline constexpr static double GetCoefficient4_3() { 65 return -7.92041454535668681958e-02; 66 } 67 GetCoefficient5_0()68 inline constexpr static double GetCoefficient5_0() { 69 return -3.70138142771437266806e-06; 70 } GetCoefficient5_1()71 inline constexpr static double GetCoefficient5_1() { 72 return 3.07033820309224325662e-01; 73 } GetCoefficient5_2()74 inline constexpr static double GetCoefficient5_2() { 75 return -2.41638288055762540107e-01; 76 } GetCoefficient5_3()77 inline constexpr static double GetCoefficient5_3() { 78 return -5.16904731562965388814e-02; 79 } GetCoefficient5_4()80 inline constexpr static double GetCoefficient5_4() { 81 return -1.36976563343097993558e-02; 82 } 83 GetCoefficient6_0()84 inline constexpr static double GetCoefficient6_0() { 85 return 1.06823753710239477000e-07; 86 } GetCoefficient6_1()87 inline constexpr static double GetCoefficient6_1() { 88 return 3.06845249656632845792e-01; 89 } GetCoefficient6_2()90 inline constexpr static double GetCoefficient6_2() { 91 return -2.40139721982230797126e-01; 92 } GetCoefficient6_3()93 inline constexpr static double GetCoefficient6_3() { 94 return -5.58662282412822480682e-02; 95 } GetCoefficient6_4()96 inline constexpr static double GetCoefficient6_4() { 97 return -8.94283890931273951763e-03; 98 } GetCoefficient6_5()99 inline constexpr static double GetCoefficient6_5() { 100 return -1.89646052380707734290e-03; 101 } 102 GetCoefficient7_0()103 inline constexpr static double GetCoefficient7_0() { 104 return -2.64303273610414963822e-09; 105 } GetCoefficient7_1()106 inline constexpr static double GetCoefficient7_1() { 107 return 3.06853075372807815313e-01; 108 } GetCoefficient7_2()109 inline constexpr static double GetCoefficient7_2() { 110 return -2.40230549677691723742e-01; 111 } GetCoefficient7_3()112 inline constexpr static double GetCoefficient7_3() { 113 return -5.54802224547989303316e-02; 114 } GetCoefficient7_4()115 inline constexpr static double GetCoefficient7_4() { 116 return -9.68497459444197204836e-03; 117 } GetCoefficient7_5()118 inline constexpr static double GetCoefficient7_5() { 119 return -1.23843111224273085859e-03; 120 } GetCoefficient7_6()121 inline constexpr static double GetCoefficient7_6() { 122 return -2.18892247566917477666e-04; 123 } 124 GetCoefficient8_0()125 inline constexpr static double GetCoefficient8_0() { 126 return 5.72265234348656066133e-11; 127 } GetCoefficient8_1()128 inline constexpr static double GetCoefficient8_1() { 129 return 3.06852812183173784266e-01; 130 } GetCoefficient8_2()131 inline constexpr static double GetCoefficient8_2() { 132 return -2.40226356058427820139e-01; 133 } GetCoefficient8_3()134 inline constexpr static double GetCoefficient8_3() { 135 return -5.55053022725605083032e-02; 136 } GetCoefficient8_4()137 inline constexpr static double GetCoefficient8_4() { 138 return -9.61350625581030605871e-03; 139 } GetCoefficient8_5()140 inline constexpr static double GetCoefficient8_5() { 141 return -1.34302437845634000529e-03; 142 } GetCoefficient8_6()143 inline constexpr static double GetCoefficient8_6() { 144 return -1.42962470418959216190e-04; 145 } GetCoefficient8_7()146 inline constexpr static double GetCoefficient8_7() { 147 return -2.16607474999407558923e-05; 148 } 149 GetCoefficient9_0()150 inline constexpr static double GetCoefficient9_0() { 151 return -1.10150186041739869460e-12; 152 } GetCoefficient9_1()153 inline constexpr static double GetCoefficient9_1() { 154 return 3.06852819617161765020e-01; 155 } GetCoefficient9_2()156 inline constexpr static double GetCoefficient9_2() { 157 return -2.40226511645233870018e-01; 158 } GetCoefficient9_3()159 inline constexpr static double GetCoefficient9_3() { 160 return -5.55040609720754696266e-02; 161 } GetCoefficient9_4()162 inline constexpr static double GetCoefficient9_4() { 163 return -9.61837182960864275905e-03; 164 } GetCoefficient9_5()165 inline constexpr static double GetCoefficient9_5() { 166 return -1.33266405715993271723e-03; 167 } GetCoefficient9_6()168 inline constexpr static double GetCoefficient9_6() { 169 return -1.55186852765468104613e-04; 170 } GetCoefficient9_7()171 inline constexpr static double GetCoefficient9_7() { 172 return -1.41484352491262699514e-05; 173 } GetCoefficient9_8()174 inline constexpr static double GetCoefficient9_8() { 175 return -1.87582286605066256753e-06; 176 } 177 GetCoefficient10_0()178 inline constexpr static double GetCoefficient10_0() { 179 return 1.79040320992239805871e-11; 180 } GetCoefficient10_1()181 inline constexpr static double GetCoefficient10_1() { 182 return 3.06852815055756844576e-01; 183 } GetCoefficient10_2()184 inline constexpr static double GetCoefficient10_2() { 185 return -2.40226385506041861806e-01; 186 } GetCoefficient10_3()187 inline constexpr static double GetCoefficient10_3() { 188 return -5.55053584940081654042e-02; 189 } GetCoefficient10_4()190 inline constexpr static double GetCoefficient10_4() { 191 return -9.61174262279892825667e-03; 192 } GetCoefficient10_5()193 inline constexpr static double GetCoefficient10_5() { 194 return -1.35164210003994454852e-03; 195 } GetCoefficient10_6()196 inline constexpr static double GetCoefficient10_6() { 197 return -1.23291147980286128769e-04; 198 } GetCoefficient10_7()199 inline constexpr static double GetCoefficient10_7() { 200 return -4.53940620364305641833e-05; 201 } GetCoefficient10_8()202 inline constexpr static double GetCoefficient10_8() { 203 return 1.46363500589519947862e-05; 204 } GetCoefficient10_9()205 inline constexpr static double GetCoefficient10_9() { 206 return -3.63750326480946818984e-06; 207 } 208 GetCoefficient11_0()209 inline constexpr static double GetCoefficient11_0() { 210 return 7.32388148129676088418e-13; 211 } GetCoefficient11_1()212 inline constexpr static double GetCoefficient11_1() { 213 return 3.06852819216552274995e-01; 214 } GetCoefficient11_2()215 inline constexpr static double GetCoefficient11_2() { 216 return -2.40226499275945526435e-01; 217 } GetCoefficient11_3()218 inline constexpr static double GetCoefficient11_3() { 219 return -5.55042073859920090384e-02; 220 } GetCoefficient11_4()221 inline constexpr static double GetCoefficient11_4() { 222 return -9.61749102796678571881e-03; 223 } GetCoefficient11_5()224 inline constexpr static double GetCoefficient11_5() { 225 return -1.33571753728242812072e-03; 226 } GetCoefficient11_6()227 inline constexpr static double GetCoefficient11_6() { 228 return -1.48718480159015542822e-04; 229 } GetCoefficient11_7()230 inline constexpr static double GetCoefficient11_7() { 231 return -2.26598047213222231406e-05; 232 } GetCoefficient11_8()233 inline constexpr static double GetCoefficient11_8() { 234 return 4.91492761180322572151e-06; 235 } GetCoefficient11_9()236 inline constexpr static double GetCoefficient11_9() { 237 return -3.00875847392884227107e-06; 238 } GetCoefficient11_10()239 inline constexpr static double GetCoefficient11_10() { 240 return 5.68126156224525271282e-07; 241 } 242 }; 243 244 #endif 245