stator
A math, geometry, and utility library
constants.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 Marcus N Campbell Bannerman <[email protected]>
3  2015 Severin Strobl <[email protected]>
4 
5  This file is part of stator.
6 
7  stator is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  stator is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with stator. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #pragma once
22 
23 // C++
24 #include <ratio>
25 #include <type_traits>
26 
27 namespace stator {
28 
38  template<typename Scalar,
39  typename = typename std::is_floating_point<Scalar>::type>
40  struct constant {
41 
43  static inline Scalar k() {
44  return Scalar(1.3806488e-23);
45  }
46 
48  static inline Scalar pi() {
49  return Scalar(3.1415926535897932384626433832795029L);
50  }
51 
53  static inline Scalar avogadro() {
54  return Scalar(6.02214129e23);
55  }
56 
58  static inline Scalar R() {
59  return avogadro() * k();
60  }
61 
63  static inline Scalar e() {
64  return Scalar(2.7182818284590452353602874713526624L);
65  }
66  };
67 
85  struct constant_ratio {
93  typedef std::ratio<47627751, 15160384> pi;
94 
103  typedef std::ratio<28245729, 10391023> e;
104  };
105 } // namespace stator
static Scalar avogadro()
Avogadro&#39;s constant .
Definition: constants.hpp:53
static Scalar e()
The base of the natural logarithm .
Definition: constants.hpp:63
Physical constants in different floating point representations.
Definition: constants.hpp:40
std::ratio< 28245729, 10391023 > e
A rational approximation of .
Definition: constants.hpp:103
static Scalar k()
Boltzmann&#39;s constant .
Definition: constants.hpp:43
Physical constants approximated in std::ratio representation.
Definition: constants.hpp:85
The stator library namespace.
Definition: frontpage.dox:243
std::ratio< 47627751, 15160384 > pi
A rational approximation of .
Definition: constants.hpp:93
static Scalar R()
The universal gas constant .
Definition: constants.hpp:58
static Scalar pi()
.
Definition: constants.hpp:48