constants_old.hpp 6.3 KB

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