constants.hpp
Go to the documentation of this file.
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2011 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12 
13 
16 
17 
18 namespace priv
19  {
21  {
22  public:
23 
24  template<typename eT>
25  static
28  {
30 
31  if(std::numeric_limits<eT>::has_quiet_NaN == true)
32  {
33  return std::numeric_limits<eT>::quiet_NaN();
34  }
35  else
36  {
37  return eT(0);
38  }
39  }
40 
41 
42  template<typename eT>
43  static
46  {
48 
49  typedef typename get_pod_type<eT>::result T;
50 
51  return eT( Math_helper::nan<T>(), Math_helper::nan<T>() );
52  }
53 
54 
55  template<typename eT>
56  static
59  {
61 
62  return eT(0);
63  }
64 
65 
66  template<typename eT>
67  static
70  {
72 
73  if(std::numeric_limits<eT>::has_infinity == true)
74  {
75  return std::numeric_limits<eT>::infinity();
76  }
77  else
78  {
80  }
81  }
82 
83 
84  template<typename eT>
85  static
88  {
90 
91  typedef typename get_pod_type<eT>::result T;
92 
93  return eT( Math_helper::inf<T>(), Math_helper::inf<T>() );
94  }
95 
96 
97  template<typename eT>
98  static
101  {
102  arma_ignore(junk);
103 
105  }
106 
107  };
108  }
109 
110 
111 
112 template<typename eT>
113 class Math
114  {
115  public:
116 
117  // the long lengths of the constants are for future support of "long double"
118  // and any smart compiler that does high-precision computation at compile-time
119 
121  static eT pi() { return eT(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679); }
122 
124  static eT e() { return eT(2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274); }
125 
127  static eT euler() { return eT(0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495); }
128 
130  static eT gratio() { return eT(1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374); }
131 
133  static eT sqrt2() { return eT(1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727); }
134 
136  static eT eps() { return std::numeric_limits<eT>::epsilon(); }
137 
139  static eT log_min() { static const eT out = std::log(std::numeric_limits<eT>::min()); return out; }
140 
142  static eT log_max() { static const eT out = std::log(std::numeric_limits<eT>::max()); return out; }
143 
145  static eT nan() { return priv::Math_helper::nan<eT>(); }
146 
148  static eT inf() { return priv::Math_helper::inf<eT>(); }
149  };
150 
151 
152 
157 template<typename eT>
158 class Phy
159  {
160  public:
161 
163  static eT m_u() { return eT(1.660538782e-27); }
164 
166  static eT N_A() { return eT(6.02214179e23); }
167 
169  static eT k() { return eT(1.3806504e-23); }
170 
172  static eT k_evk() { return eT(8.617343e-5); }
173 
175  static eT a_0() { return eT(0.52917720859e-10); }
176 
178  static eT mu_B() { return(927.400915e-26); }
179 
181  static eT Z_0() { return eT(3.76730313461771e-2); }
182 
184  static eT G_0() { return eT(7.7480917004e-5); }
185 
187  static eT k_e() { return eT(8.9875517873681764e9); }
188 
190  static eT eps_0() { return eT(8.85418781762039e-12); }
191 
193  static eT m_e() { return eT(9.10938215e-31); }
194 
196  static eT eV() { return eT(1.602176487e-19); }
197 
199  static eT e() { return eT(1.602176487e-19); }
200 
202  static eT F() { return eT(96485.3399); }
203 
205  static eT alpha() { return eT(7.2973525376e-3); }
206 
208  static eT alpha_inv() { return eT(137.035999679); }
209 
211  static eT K_J() { return eT(483597.891e9); }
212 
214  static eT mu_0() { return eT(1.25663706143592e-06); }
215 
217  static eT phi_0() { return eT(2.067833667e-15); }
218 
220  static eT R() { return eT(8.314472); }
221 
223  static eT G() { return eT(6.67428e-11); }
224 
226  static eT h() { return eT(6.62606896e-34); }
227 
229  static eT h_bar() { return eT(1.054571628e-34); }
230 
232  static eT m_p() { return eT(1.672621637e-27); }
233 
235  static eT R_inf() { return eT(10973731.568527); }
236 
238  static eT c_0() { return eT(299792458.0); }
239 
241  static eT sigma() { return eT(5.670400e-8); }
242 
244  static eT R_k() { return eT(25812.807557); }
245 
247  static eT b() { return eT(2.8977685e-3); }
248  };
249 
250 
251 
254 
255 typedef Phy<float> fphy;
256 typedef Phy<double> phy;
257 
258 
259 
260 namespace priv
261  {
262 
263  template<typename eT>
264  static
266  arma_hot
269  {
270  arma_ignore(junk);
271 
272  if(std::numeric_limits<eT>::has_infinity == true)
273  {
274  return -(std::numeric_limits<eT>::infinity());
275  }
276  else
277  {
278  return -(std::numeric_limits<eT>::max());
279  }
280  }
281 
282 
283  template<typename eT>
284  static
286  arma_hot
289  {
290  arma_ignore(junk);
291 
293  }
294 
295 
296  template<typename eT>
297  static
299  arma_hot
302  {
303  arma_ignore(junk);
304 
305  if(std::numeric_limits<eT>::has_infinity == true)
306  {
307  return std::numeric_limits<eT>::infinity();
308  }
309  else
310  {
312  }
313  }
314 
315 
316  template<typename eT>
317  static
319  arma_hot
322  {
323  arma_ignore(junk);
324 
326  }
327 
328  }
329 
330 
331 
static eT mu_B()
Bohr magneton.
Definition: constants.hpp:178
static eT nan()
"not a number"
Definition: constants.hpp:145
static arma_float_only< eT >::result nan(typename arma_float_only< eT >::result *junk=0)
Definition: constants.hpp:27
Phy< double > phy
Definition: constants.hpp:256
static eT sigma()
Stefan-Boltzmann constant.
Definition: constants.hpp:241
static eT G_0()
conductance quantum (in siemens)
Definition: constants.hpp:184
static eT k_evk()
Boltzmann constant (in eV/K)
Definition: constants.hpp:172
static eT alpha()
fine-structure constant
Definition: constants.hpp:205
Math< double > math
Definition: constants.hpp:253
static arma_float_only< eT >::result inf(typename arma_float_only< eT >::result *junk=0)
Definition: constants.hpp:69
static arma_integral_only< eT >::result inf(typename arma_integral_only< eT >::result *junk=0)
Definition: constants.hpp:100
static arma_inline arma_hot arma_float_only< eT >::result most_neg(typename arma_float_only< eT >::result *junk=0)
Definition: constants.hpp:268
static eT e()
base of the natural logarithm
Definition: constants.hpp:124
static eT F()
Faraday constant (in coulombs)
Definition: constants.hpp:202
static eT inf()
infinity
Definition: constants.hpp:148
arma_inline const Op< T1, op_max > max(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed &#39;maximum values&#39; operation. The dimension, along which the maxima are found, is set via &#39;dim&#39;. For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). The default is dim = 0.
Definition: fn_max.hpp:28
static eT euler()
Euler&#39;s constant, aka Euler-Mascheroni constant.
Definition: constants.hpp:127
static eT mu_0()
magnetic constant (in henries per meter)
Definition: constants.hpp:214
static eT e()
elementary charge (in coulombs)
Definition: constants.hpp:199
static eT c_0()
speed of light in vacuum (in meters per second)
Definition: constants.hpp:238
static eT Z_0()
characteristic impedance of vacuum (in ohms)
Definition: constants.hpp:181
arma_inline const Op< T1, op_min > min(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed &#39;minimum values&#39; operation. The dimension, along which the minima are found, is set via &#39;dim&#39;. For dim = 0, the minimum value of each column is found (i.e. searches by traversing across rows). For dim = 1, the minimum value of each row is found (i.e. searches by traversing across columns). The default is dim = 0.
Definition: fn_min.hpp:27
static eT R_k()
von Klitzing constant (in ohms)
Definition: constants.hpp:244
static eT a_0()
Bohr radius (in meters)
Definition: constants.hpp:175
static eT k()
Boltzmann constant (in joules per kelvin)
Definition: constants.hpp:169
static eT m_e()
electron mass (in kg)
Definition: constants.hpp:193
static arma_cx_only< eT >::result inf(typename arma_cx_only< eT >::result *junk=0)
Definition: constants.hpp:87
static eT eps_0()
electric constant (in farads per meter)
Definition: constants.hpp:190
static eT k_e()
Coulomb&#39;s constant (in meters per farad)
Definition: constants.hpp:187
static eT h()
Planck constant (in joule seconds)
Definition: constants.hpp:226
static eT phi_0()
magnetic flux quantum (in webers)
Definition: constants.hpp:217
static eT b()
Wien wavelength displacement law constant.
Definition: constants.hpp:247
#define arma_ignore(variable)
static eT gratio()
golden ratio
Definition: constants.hpp:130
static eT sqrt2()
square root of 2
Definition: constants.hpp:133
static arma_inline arma_hot arma_float_only< eT >::result most_pos(typename arma_float_only< eT >::result *junk=0)
Definition: constants.hpp:301
static eT m_u()
atomic mass constant (in kg)
Definition: constants.hpp:163
static eT log_min()
log of the minimum representable value
Definition: constants.hpp:139
static eT G()
Newtonian constant of gravitation (in newton square meters per kilogram squared)
Definition: constants.hpp:223
static eT eV()
electron volt (in joules)
Definition: constants.hpp:196
static eT K_J()
Josephson constant.
Definition: constants.hpp:211
static eT alpha_inv()
inverse fine-structure constant
Definition: constants.hpp:208
#define arma_inline
Phy< float > fphy
Definition: constants.hpp:255
static eT pi()
ratio of any circle&#39;s circumference to its diameter
Definition: constants.hpp:121
arma_inline const eOp< T1, eop_log > log(const Base< typename T1::elem_type, T1 > &A)
Definition: fn_elem.hpp:156
static eT R()
molar gas constant (in joules per mole kelvin)
Definition: constants.hpp:220
static arma_cx_only< eT >::result nan(typename arma_cx_only< eT >::result *junk=0)
Definition: constants.hpp:45
static eT R_inf()
Rydberg constant (in reciprocal meters)
Definition: constants.hpp:235
static eT h_bar()
Planck constant over 2 pi, aka reduced Planck constant (in joule seconds)
Definition: constants.hpp:229
static eT N_A()
Avogadro constant.
Definition: constants.hpp:166
static arma_integral_only< eT >::result nan(typename arma_integral_only< eT >::result *junk=0)
Definition: constants.hpp:58
#define arma_hot
static eT log_max()
log of the maximum representable value
Definition: constants.hpp:142
static eT eps()
the difference between 1 and the least value greater than 1 that is representable ...
Definition: constants.hpp:136
Math< float > fmath
Definition: constants.hpp:252
static eT m_p()
proton mass (in kg)
Definition: constants.hpp:232


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:56