1 // SPDX-License-Identifier: Apache-2.0
2 //
3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
4 // Copyright 2008-2016 National ICT Australia (NICTA)
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // ------------------------------------------------------------------------
17 
18 
19 //! \addtogroup constants_old
20 //! @{
21 
22 
23 // DO NOT USE IN NEW CODE !!!
24 // the Math and Phy classes are kept for compatibility with old code;
25 // for new code, use the Datum class instead
26 // eg. instead of math::pi(), use datum::pi
27 
28 template<typename eT>
29 class Math
30   {
31   public:
32 
33   // the long lengths of the constants are for future support of "long double"
34   // and any smart compiler that does high-precision computation at compile-time
35 
36   //! ratio of any circle's circumference to its diameter
pi()37   arma_deprecated static eT pi()        { return eT(Datum<eT>::pi); }  // use datum::pi instead
38 
39   //! base of the natural logarithm
e()40   arma_deprecated static eT e()         { return eT(Datum<eT>::e); }  // use datum::e instead
41 
42   //! Euler's constant, aka Euler-Mascheroni constant
euler()43   arma_deprecated static eT euler()     { return eT(Datum<eT>::euler); }  // use datum::euler instead
44 
45   //! golden ratio
gratio()46   arma_deprecated static eT gratio()    { return eT(Datum<eT>::gratio); }  // use datum::gratio instead
47 
48   //! square root of 2
sqrt2()49   arma_deprecated static eT sqrt2()     { return eT(Datum<eT>::sqrt2); }  // use datum::sqrt2 instead
50 
51   //! the difference between 1 and the least value greater than 1 that is representable
eps()52   arma_deprecated static eT eps()       { return eT(Datum<eT>::eps); }  // use datum::eps instead
53 
54   //! log of the minimum representable value
log_min()55   arma_deprecated static eT log_min()   { return eT(Datum<eT>::log_min); }  // use datum::log_min instead
56 
57   //! log of the maximum representable value
log_max()58   arma_deprecated static eT log_max()   { return eT(Datum<eT>::log_max); }  // use datum::log_max instead
59 
60   //! "not a number"
nan()61   arma_deprecated static eT nan()       { return eT(Datum<eT>::nan); }  // use datum::nan instead
62 
63   //! infinity
inf()64   arma_deprecated static eT inf()       { return eT(Datum<eT>::inf); }  // use datum::inf instead
65   };
66 
67 
68 
69 //! Physical constants taken from NIST 2010 CODATA values, and some from WolframAlpha (values provided as of 2009-06-23)
70 //! http://physics.nist.gov/cuu/Constants
71 //! http://www.wolframalpha.com
72 //! See also http://en.wikipedia.org/wiki/Physical_constant
73 template<typename eT>
74 class Phy
75   {
76   public:
77 
78   //! atomic mass constant (in kg)
m_u()79   arma_deprecated static eT m_u()       { return eT(Datum<eT>::m_u); }
80 
81   //! Avogadro constant
N_A()82   arma_deprecated static eT N_A()       { return eT(Datum<eT>::N_A); }
83 
84   //! Boltzmann constant (in joules per kelvin)
k()85   arma_deprecated static eT k()         { return eT(Datum<eT>::k); }
86 
87   //! Boltzmann constant (in eV/K)
k_evk()88   arma_deprecated static eT k_evk()     { return eT(Datum<eT>::k_evk); }
89 
90   //! Bohr radius (in meters)
a_0()91   arma_deprecated static eT a_0()       { return eT(Datum<eT>::a_0); }
92 
93   //! Bohr magneton
mu_B()94   arma_deprecated static eT mu_B()      { return eT(Datum<eT>::mu_B); }
95 
96   //! characteristic impedance of vacuum (in ohms)
Z_0()97   arma_deprecated static eT Z_0()       { return eT(Datum<eT>::Z_0); }
98 
99   //! conductance quantum (in siemens)
G_0()100   arma_deprecated static eT G_0()       { return eT(Datum<eT>::G_0); }
101 
102   //! Coulomb's constant (in meters per farad)
k_e()103   arma_deprecated static eT k_e()       { return eT(Datum<eT>::k_e); }
104 
105   //! electric constant (in farads per meter)
eps_0()106   arma_deprecated static eT eps_0()     { return eT(Datum<eT>::eps_0); }
107 
108   //! electron mass (in kg)
m_e()109   arma_deprecated static eT m_e()       { return eT(Datum<eT>::m_e); }
110 
111   //! electron volt (in joules)
eV()112   arma_deprecated static eT eV()        { return eT(Datum<eT>::eV); }
113 
114   //! elementary charge (in coulombs)
e()115   arma_deprecated static eT e()         { return eT(Datum<eT>::ec); }
116 
117   //! Faraday constant (in coulombs)
F()118   arma_deprecated static eT F()         { return eT(Datum<eT>::F); }
119 
120   //! fine-structure constant
alpha()121   arma_deprecated static eT alpha()     { return eT(Datum<eT>::alpha); }
122 
123   //! inverse fine-structure constant
alpha_inv()124   arma_deprecated static eT alpha_inv() { return eT(Datum<eT>::alpha_inv); }
125 
126   //! Josephson constant
K_J()127   arma_deprecated static eT K_J()       { return eT(Datum<eT>::K_J); }
128 
129   //! magnetic constant (in henries per meter)
mu_0()130   arma_deprecated static eT mu_0()      { return eT(Datum<eT>::mu_0); }
131 
132   //! magnetic flux quantum (in webers)
phi_0()133   arma_deprecated static eT phi_0()     { return eT(Datum<eT>::phi_0); }
134 
135   //! molar gas constant (in joules per mole kelvin)
R()136   arma_deprecated static eT R()         { return eT(Datum<eT>::R); }
137 
138   //! Newtonian constant of gravitation (in newton square meters per kilogram squared)
G()139   arma_deprecated static eT G()         { return eT(Datum<eT>::G); }
140 
141   //! Planck constant (in joule seconds)
h()142   arma_deprecated static eT h()         { return eT(Datum<eT>::h); }
143 
144   //! Planck constant over 2 pi, aka reduced Planck constant (in joule seconds)
h_bar()145   arma_deprecated static eT h_bar()     { return eT(Datum<eT>::h_bar); }
146 
147   //! proton mass (in kg)
m_p()148   arma_deprecated static eT m_p()       { return eT(Datum<eT>::m_p); }
149 
150   //! Rydberg constant (in reciprocal meters)
R_inf()151   arma_deprecated static eT R_inf()     { return eT(Datum<eT>::R_inf); }
152 
153   //! speed of light in vacuum (in meters per second)
c_0()154   arma_deprecated static eT c_0()       { return eT(Datum<eT>::c_0); }
155 
156   //! Stefan-Boltzmann constant
sigma()157   arma_deprecated static eT sigma()     { return eT(Datum<eT>::sigma); }
158 
159   //! von Klitzing constant (in ohms)
R_k()160   arma_deprecated static eT R_k()       { return eT(Datum<eT>::R_k); }
161 
162   //! Wien wavelength displacement law constant
b()163   arma_deprecated static eT b()         { return eT(Datum<eT>::b); }
164   };
165 
166 
167 
168 typedef Math<float>  fmath;
169 typedef Math<double> math;
170 
171 typedef Phy<float>   fphy;
172 typedef Phy<double>  phy;
173 
174 
175 
176 //! @}
177