typedefs.hh

Go to the documentation of this file.
1 
6 #ifndef typedefs_hh
7 #define typedefs_hh
8 
9 #define _USE_MATH_DEFINES
10 #include <cmath>
11 // Define the constant M_PI, if not defined (e.g. with Windows Microsoft C++ compiler)
12 #ifndef M_PI
13 #define M_PI 3.14159265358979323846264338327
14 #endif
15 
16 // Define the epsilon machine, i.e. the difference between 1 and the next representable value of double type
17 #if __GNUC__ == 2
18 # include <float.h>
19 # define EPS DBL_EPSILON
20 #else
21 # include <limits>
22 # define EPS std::numeric_limits<double>::epsilon()
23 #endif
24 
25 #include <sys/types.h>
26 #include <string>
27 #include <complex>
28 
29 namespace concepts {
30 
36  typedef double Real;
37 
39  typedef std::complex<Real> Cmplx;
40 
42  typedef signed int sint;
43 
45  typedef unsigned char uchar;
46 
48  typedef unsigned short ushort;
49 
50  // **************************************************************** number **
51 
67  template<typename F>
68  struct number {};
69 
71  template<>
72  struct number<double> {
73  static inline std::string name() { return "double"; }
74  };
75 
77  template<>
78  struct number<long double> {
79  static inline std::string name() { return "long double"; }
80  };
81 
83  template<>
84  struct number<std::complex<double> > {
85  static inline std::string name() { return "complex<double>"; }
86  };
87 
89  template<>
90  struct number<std::complex<long double> > {
91  static inline std::string name() { return "complex<long double>"; }
92  };
93 
94  // ************************************************************** Realtype **
95 
99  template<typename F>
100  struct Realtype {
101  typedef F type;
102  };
103 
104  template<typename F>
105  struct Realtype<std::complex<F> > {
106  typedef F type;
107  };
108 
109  // ************************************************************* Cmplxtype **
110 
114  template<typename F>
115  struct Cmplxtype {
116  typedef std::complex<F> type;
117  };
118 
119  template<typename F>
120  struct Cmplxtype<std::complex<F> > {
121  typedef std::complex<F> type;
122  };
123 
124  // ************************************************************** Combtype **
125 
134  template<typename F, typename G>
135  struct Combtype {
136  typedef F type;
137  };
138 
142  template<typename F>
143  struct Combtype<std::complex<F>, F> {
144  typedef std::complex<F> type;
145  };
146 
150  template<typename F>
151  struct Combtype<F, std::complex<F> > {
152  typedef std::complex<F> type;
153  };
154 
159  template<typename F>
160  struct Combtype<int, F> {
161  typedef F type;
162  };
163 
164  // ************************************************************** Datatype **
165 
168  template<typename F>
169  struct Datatype {
170  typedef F type;
171  };
172 
173 } // namespace concepts
174 
175 #endif // typedefs_hh
Type of the data inside a container.
Definition: typedefs.hh:169
unsigned char uchar
Abbreviation for unsigned char.
Definition: typedefs.hh:45
static std::string name()
Definition: typedefs.hh:79
static std::string name()
Definition: typedefs.hh:73
Name traits for number types.
Definition: typedefs.hh:68
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
Combined type.
Definition: typedefs.hh:135
Taking for a complex type the appropiate real type and for a real type itself.
Definition: typedefs.hh:100
unsigned short ushort
Abbreviation for unsigned short.
Definition: typedefs.hh:48
signed int sint
Abbreviation for signed int.
Definition: typedefs.hh:42
std::complex< F > type
Definition: typedefs.hh:116
Taking for a real type the appropiate real type and for a real type itself.
Definition: typedefs.hh:115
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich