Code-Eli  0.3.6
math.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2 * Copyright (c) 2013 David D. Marshall <ddmarsha@calpoly.edu>
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * David D. Marshall - initial code and implementation
11 ********************************************************************************/
12 
13 #ifndef eli_constants_math_hpp
14 #define eli_constants_math_hpp
15 
16 #include <cmath>
17 
18 #include "eli/code_eli.hpp"
19 
20 namespace eli
21 {
22  namespace constants
23  {
24  template <typename T__>
25  class math
26  {
27  };
28 
29  template<>
30  class math <float>
31  {
32  public:
33  static float exp() {return 2.7182818f;}
34  static float ln_two() {return 0.6931472f;}
35  static float log_exp() {return 0.43429447f;}
36 
37  static float pi() {return 3.1415927f;}
38  static float two_pi() {return 6.2831853f;}
39  static float pi_by_two() {return 1.57079633f;}
40  static float pi_by_four() {return 0.78539816f;}
41  static float pi_squared() {return 9.8696046f;}
42  static float pi_cubed() {return 31.006279f;}
43  static float sqrt_pi() {return 1.7724539f;}
44  static float cbrt_pi() {return 1.4645919f;}
45  static float one_by_pi() {return 0.31830988f;}
46  static float two_by_pi() {return 0.63661977f;}
47  static float one_by_sqrt_pi() {return 0.56418958f;}
48  static float two_by_sqrt_pi() {return 1.12837916f;}
49 
50  static float sqrt_two() {return 1.41421356f;}
51  static float sqrt_two_by_two() {return 0.70710678f;}
52  };
53 
54  template <>
55  class math <double>
56  {
57  public:
58  static const double exp1;
59 
60  public:
61  static double exp() {return 2.718281828459045;}
62  static double ln_two() {return 0.6931471805599453;}
63  static double log_exp() {return 0.4342944819032518;}
64 
65  static double pi() {return 3.141592653589793;}
66  static double two_pi() {return 6.283185307179586;}
67  static double pi_by_two() {return 1.5707963267948966;}
68  static double pi_by_four() {return 0.7853981633974483;}
69  static double pi_squared() {return 9.8696044010893586;}
70  static double pi_cubed() {return 31.006276680299817;}
71  static double sqrt_pi() {return 1.7724538509055159;}
72 #if defined(_MSC_VER)
73 # if (_MSC_VER==1800)
74  static double cbrt_pi() {return 1.4645918875615233;}
75 # else
76  static double cbrt_pi() { return 1.4645918875615231; }
77 # endif
78 #elif defined(__INTEL_COMPILER)
79  static double cbrt_pi() {return 1.4645918875615231;}
80 #elif defined(__clang__)
81  static double cbrt_pi() {return 1.4645918875615233;}
82 #elif defined(__GNUC__)
83 # if (__GNUC__==4) && (__GNUC_MINOR__>=7) && (defined NDEBUG)
84  static double cbrt_pi() {return 1.4645918875615231;}
85 # else
86  static double cbrt_pi() {return 1.4645918875615233;}
87 # endif
88 #else
89  static double cbrt_pi() {return 1.4645918875615231;}
90 #endif
91  static double one_by_pi() {return 0.31830988618379067;}
92  static double two_by_pi() {return 0.63661977236758134;}
93  static double one_by_sqrt_pi() {return 0.56418958354775629;}
94  static double two_by_sqrt_pi() {return 1.1283791670955126;}
95 
96  static double sqrt_two() {return 1.41421356237309504;}
97  static double sqrt_two_by_two() {return 0.70710678118654752;}
98  };
99 
100  template<>
101  class math <long double>
102  {
103  public:
104  static long double exp() {return 2.7182818284590452354L;}
105  static long double ln_two() {return 0.69314718055994530942L;}
106  static long double log_exp() {return 0.43429448190325182766L;}
107 
108  static long double pi() {return 3.1415926535897932385L;}
109  static long double two_pi() {return 6.2831853071795864770L;}
110  static long double pi_by_two() {return 1.57079632679489661923L;}
111  static long double pi_by_four() {return 0.78539816339744830962L;}
112  static long double pi_squared() {return 9.869604401089358619L;}
113 #ifdef _MSC_VER
114  static long double pi_cubed() {return 31.006276680299817L;}
115  static long double sqrt_pi() {return 1.7724538509055159L;}
116 # if (_MSC_VER==1800)
117  static long double cbrt_pi() {return 1.4645918875615233L;}
118 # else
119  static long double cbrt_pi() {return 1.4645918875615231L;}
120 # endif
121 #else
122  static long double pi_cubed() {return 31.0062766802998201763L;}
123  static long double sqrt_pi() {return 1.7724538509055160273L;}
124  static long double cbrt_pi() {return 1.464591887561523263L;}
125 #endif
126  static long double one_by_pi() {return 0.31830988618379067154L;}
127  static long double two_by_pi() {return 0.6366197723675813431L;}
128  static long double one_by_sqrt_pi() {return 0.5641895835477562869L;}
129  static long double two_by_sqrt_pi() {return 1.1283791670955125738L;}
130 
131  static long double sqrt_two() {return 1.4142135623730950488L;}
132  static long double sqrt_two_by_two() {return 0.7071067811865475244L;}
133  };
134  }
135 }
136 
137 #endif
static double sqrt_pi()
Definition: math.hpp:71
static float pi_cubed()
Definition: math.hpp:42
Definition: math.hpp:20
static long double pi()
Definition: math.hpp:108
static long double exp()
Definition: math.hpp:104
static double exp()
Definition: math.hpp:61
static float exp()
Definition: math.hpp:33
static float pi_by_four()
Definition: math.hpp:40
static float pi_by_two()
Definition: math.hpp:39
static double pi_cubed()
Definition: math.hpp:70
static long double one_by_sqrt_pi()
Definition: math.hpp:128
static float one_by_sqrt_pi()
Definition: math.hpp:47
static long double log_exp()
Definition: math.hpp:106
static long double sqrt_two()
Definition: math.hpp:131
static long double sqrt_two_by_two()
Definition: math.hpp:132
static double cbrt_pi()
Definition: math.hpp:89
static long double one_by_pi()
Definition: math.hpp:126
static float pi_squared()
Definition: math.hpp:41
Definition: math.hpp:25
static long double two_by_sqrt_pi()
Definition: math.hpp:129
static double two_by_sqrt_pi()
Definition: math.hpp:94
static double one_by_sqrt_pi()
Definition: math.hpp:93
static float pi()
Definition: math.hpp:37
static double ln_two()
Definition: math.hpp:62
static float two_by_sqrt_pi()
Definition: math.hpp:48
static double sqrt_two_by_two()
Definition: math.hpp:97
static float cbrt_pi()
Definition: math.hpp:44
static long double pi_cubed()
Definition: math.hpp:122
static double two_by_pi()
Definition: math.hpp:92
static float sqrt_pi()
Definition: math.hpp:43
static long double pi_by_two()
Definition: math.hpp:110
static double log_exp()
Definition: math.hpp:63
static long double two_by_pi()
Definition: math.hpp:127
static long double two_pi()
Definition: math.hpp:109
static float two_by_pi()
Definition: math.hpp:46
static double pi_by_four()
Definition: math.hpp:68
static long double pi_squared()
Definition: math.hpp:112
static double pi_by_two()
Definition: math.hpp:67
static float sqrt_two_by_two()
Definition: math.hpp:51
static const double exp1
Definition: math.hpp:58
static long double sqrt_pi()
Definition: math.hpp:123
static double one_by_pi()
Definition: math.hpp:91
static long double ln_two()
Definition: math.hpp:105
static float sqrt_two()
Definition: math.hpp:50
static double sqrt_two()
Definition: math.hpp:96
static long double cbrt_pi()
Definition: math.hpp:124
static float one_by_pi()
Definition: math.hpp:45
static double pi()
Definition: math.hpp:65
static double pi_squared()
Definition: math.hpp:69
static float ln_two()
Definition: math.hpp:34
static long double pi_by_four()
Definition: math.hpp:111
static float log_exp()
Definition: math.hpp:35
static double two_pi()
Definition: math.hpp:66
static float two_pi()
Definition: math.hpp:38