constants.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup constants
00017 //! @{
00018 
00019 
00020 // the long lengths of the constants are for future support of "long double"
00021 // and any smart compiler that does high-precision computation at compile-time
00022 
00023 template<typename eT>
00024 class Math
00025   {
00026   public:
00027   
00028   //! ratio of any circle's circumference to its diameter
00029   static const eT pi()        { return eT(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679); }
00030   
00031   //! base of the natural logarithm
00032   static const eT e()         { return eT(2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274); }
00033   
00034   //! Euler's constant, aka Euler-Mascheroni constant
00035   static const eT euler()     { return eT(0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495); }
00036   
00037   //! golden ratio
00038   static const eT gratio()    { return eT(1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374); }
00039   
00040   //! square root of 2
00041   static const eT sqrt2()     { return eT(1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727); }
00042   
00043   //! the difference between 1 and the least value greater than 1 that is representable
00044   static const eT eps()       { return std::numeric_limits<eT>::epsilon(); }
00045   
00046   //! log of the minimum representable value
00047   static const eT log_min()   { static const eT out = std::log(std::numeric_limits<eT>::min()); return out; }
00048     
00049   //! log of the maximum representable value
00050   static const eT log_max()   { static const eT out = std::log(std::numeric_limits<eT>::max()); return out; }
00051   };
00052 
00053 
00054 
00055 //! Physical constants taken from NIST and WolframAlpha on 2009-06-23
00056 //! http://physics.nist.gov/cuu/Constants
00057 //! http://www.wolframalpha.com
00058 //! See also http://en.wikipedia.org/wiki/Physical_constant
00059 template<typename eT>
00060 class Phy
00061   {
00062   public:
00063 
00064   //! atomic mass constant (in kg)
00065   static const eT m_u()       {  return eT(1.660538782e-27); }
00066 
00067   //! Avogadro constant
00068   static const eT N_A()       {  return eT(6.02214179e23); }
00069 
00070   //! Boltzmann constant (in joules per kelvin)
00071   static const eT k()         {  return eT(1.3806504e-23); }
00072 
00073   //! Boltzmann constant (in eV/K)
00074   static const eT k_evk()     {  return eT(8.617343e-5); }
00075 
00076   //! Bohr radius (in meters)
00077   static const eT a_0()       { return eT(0.52917720859e-10); }
00078 
00079   //! Bohr magneton
00080   static const eT mu_B()      { return(927.400915e-26); }
00081 
00082   //! characteristic impedance of vacuum (in ohms)
00083   static const eT Z_0()       { return eT(3.76730313461771e-2); }
00084 
00085   //! conductance quantum (in siemens)
00086   static const eT G_0()       { return eT(7.7480917004e-5); }
00087 
00088   //! Coulomb's constant (in meters per farad)
00089   static const eT k_e()       { return eT(8.9875517873681764e9); }
00090 
00091   //! electric constant (in farads per meter)
00092   static const eT eps_0()     { return eT(8.85418781762039e-12); }
00093 
00094   //! electron mass (in kg)
00095   static const eT m_e()       { return eT(9.10938215e-31); }
00096 
00097   //! electron volt (in joules)
00098   static const eT eV()        { return eT(1.602176487e-19); }
00099 
00100   //! elementary charge (in coulombs)
00101   static const eT e()         { return eT(1.602176487e-19); }
00102   
00103   //! Faraday constant (in coulombs)
00104   static const eT F()         { return eT(96485.3399); }
00105 
00106   //! fine-structure constant
00107   static const eT alpha()     { return eT(7.2973525376e-3); }
00108 
00109   //! inverse fine-structure constant
00110   static const eT alpha_inv() { return eT(137.035999679); }
00111 
00112   //! Josephson constant
00113   static const eT K_J()       { return eT(483597.891e9); }
00114 
00115   //! magnetic constant (in henries per meter)
00116   static const eT mu_0()      { return eT(1.25663706143592e-06); }
00117 
00118   //! magnetic flux quantum (in webers)
00119   static const eT phi_0()     { return eT(2.067833667e-15); }
00120 
00121   //! molar gas constant (in joules per mole kelvin)
00122   static const eT R()         { return eT(8.314472); }
00123 
00124   //! Newtonian constant of gravitation (in newton square meters per kilogram squared)
00125   static const eT G()         { return eT(6.67428e-11); }
00126 
00127   //! Planck constant (in joule seconds)
00128   static const eT h()         { return eT(6.62606896e-34); }
00129 
00130   //! Planck constant over 2 pi, aka reduced Planck constant (in joule seconds)
00131   static const eT h_bar()     { return eT(1.054571628e-34); }
00132 
00133   //! proton mass (in kg)
00134   static const eT m_p()       { return eT(1.672621637e-27); }
00135 
00136   //! Rydberg constant (in reciprocal meters)
00137   static const eT R_inf()     { return eT(10973731.568527); }
00138 
00139   //! speed of light in vacuum (in meters per second)
00140   static const eT c_0()       { return eT(299792458.0); }
00141 
00142   //! Stefan-Boltzmann constant
00143   static const eT sigma()     { return eT(5.670400e-8); }
00144 
00145   //! von Klitzing constant (in ohms)
00146   static const eT R_k()       { return eT(25812.807557); }
00147 
00148   //! Wien wavelength displacement law constant
00149   static const eT b()         { return eT(2.8977685e-3); }
00150   };
00151 
00152 
00153 
00154 typedef Math<float>  fmath;
00155 typedef Math<double> math;
00156 
00157 typedef Phy<float>   fphy;
00158 typedef Phy<double>  phy;
00159 
00160 
00161 
00162 struct arma_version
00163   {
00164   static const unsigned int major = 0;
00165   static const unsigned int minor = 6;
00166   static const unsigned int patch = 12;
00167   };
00168 
00169 
00170 
00171 struct arma_config
00172   {
00173   #if defined(ARMA_USE_ATLAS)
00174     static const bool atlas = true;
00175   #else
00176     static const bool atlas = false;
00177   #endif
00178   
00179   
00180   #if defined(ARMA_USE_LAPACK)
00181     static const bool lapack = true;
00182   #else
00183     static const bool lapack = false;
00184   #endif
00185   
00186   
00187   #if defined(ARMA_USE_BLAS)
00188     static const bool blas = true;
00189   #else
00190     static const bool blas = false;
00191   #endif
00192 
00193 
00194   #if defined(ARMA_USE_BOOST)
00195     static const bool boost = true;
00196   #else
00197     static const bool boost = false;
00198   #endif
00199   
00200 
00201   #if defined(ARMA_USE_BOOST_DATE)
00202     static const bool boost_date = true;
00203   #else
00204     static const bool boost_date = false;
00205   #endif
00206 
00207 
00208   #if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG)
00209     static const bool debug = true;
00210   #else
00211     static const bool debug = false;
00212   #endif
00213   
00214   
00215   #if defined(ARMA_EXTRA_DEBUG)
00216     static const bool extra_debug = true;
00217   #else
00218     static const bool extra_debug = false;
00219   #endif
00220   };
00221 
00222 //! @}
00223 
00224