flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
mathdefs.hpp
Go to the documentation of this file.
1#ifndef mathdefs_hpp
2#define mathdefs_hpp
3
4#include "wrappers.hpp"
5
6#include <cmath>
7#include <complex>
8#include <limits>
9
10namespace flexiblesusy {
11
12using Real = double;
13using Comp = std::complex<Real>;
14
15
16constexpr double pi = Pi;
17constexpr double r2 = 1.4142135623730950;
19
20
21template<unsigned p, bool even_p, class T>
22struct _power;
23
24template<unsigned p, class T>
25struct _power<p, true, T> {
26 static T f(T x) {
27 return _power<p/2, (p/2) % 2 == 0, T>::f(x) *
28 _power<p/2, (p/2) % 2 == 0, T>::f(x);
29 }
30};
31
32template<unsigned p, class T>
33struct _power<p, false, T> {
34 static T f(T x) {
35 return _power<p-1, (p-1) % 2 == 0, T>::f(x) * x;
36 }
37};
38
39template<class T>
40struct _power<1, false, T> {
41 static T f(T x) {
42 return x;
43 }
44};
45
46template<class T>
47struct _power<0, true, T> {
48 static T f(T /* x */) {
49 return 1;
50 }
51};
52
53template<unsigned p, class T> inline T Pow(T x)
54{
56}
57
58template<class T> inline T Pow2(T x) { return Pow<2>(x); }
59template<class T> inline T Pow3(T x) { return Pow<3>(x); }
60template<class T> inline T Pow4(T x) { return Pow<4>(x); }
61template<class T> inline T Pow5(T x) { return Pow<5>(x); }
62template<class T> inline T sqr (T x) { return Pow<2>(x); }
63template<class T> inline T cube(T x) { return Pow<3>(x); }
64
65template<class T> inline T sign(T x)
66{
67 if (x == 0) return 0;
68 else if (x > 0) return 1;
69 else return -1;
70}
71
72} // namespace flexiblesusy
73
74#endif // mathdefs_hpp
T sqr(T x)
Definition: mathdefs.hpp:62
const Real epsilon
Definition: mathdefs.hpp:18
std::complex< double > f(double tau) noexcept
double Real
Definition: mathdefs.hpp:12
std::complex< Real > Comp
Definition: mathdefs.hpp:13
T Pow4(T x)
Definition: mathdefs.hpp:60
T sign(T x)
Definition: mathdefs.hpp:65
T Pow2(T x)
Definition: mathdefs.hpp:58
T Pow(T x)
Definition: mathdefs.hpp:53
T Pow5(T x)
Definition: mathdefs.hpp:61
constexpr double r2
Definition: mathdefs.hpp:17
constexpr double pi
Definition: mathdefs.hpp:16
static constexpr double Pi
Definition: wrappers.hpp:44
T cube(T x)
Definition: mathdefs.hpp:63
T Pow3(T x)
Definition: mathdefs.hpp:59