GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cpp11_fixes.h
Go to the documentation of this file.
1 
6 #ifndef GHOST_CPP11_FIXES_H
7 #define GHOST_CPP11_FIXES_H
8 
9 #include <string>
10 #include <sstream>
11 #include <complex>
12 
13 namespace ghost {
14 
15 // Difference between ghost::conj_or_nop and std::conj
16 // std::conj(double) -> std::complex<double>
17 // ghost::conj_or_nop(double) -> double
18 template<typename T>
19 static inline T conj_or_nop(const T &a)
20 {
21  return std::conj(a);
22 }
23 
24 static inline float conj_or_nop(const float &a) { return a; }
25 
26 static inline double conj_or_nop(const double &a) { return a; }
27 
28 template<typename T>
29 static inline T norm(const T &a)
30 {
31  return std::norm(a);
32 }
33 
34 #if __cplusplus < 201103L
35 static inline float norm(const float &a)
36 {
37  /*return std::fabs(a);*/
38  return a * a;
39 }
40 
41 static inline double norm(const double &a)
42 {
43  /*return std::fabs(a);*/
44  return a * a;
45 }
46 #endif
47 
48 #if __cplusplus < 201103L
49 template<typename T>
50 static inline std::string to_string(T value)
51 {
52  std::stringstream ss;
53  ss << value;
54  return ss.str();
55 }
56 #else
57 template<typename T>
58 static inline std::string to_string(T value)
59 {
60  return std::to_string(value);
61 }
62 #endif
63 }
64 
65 #endif
static double norm(const double &a)
Definition: cpp11_fixes.h:41
static T conj_or_nop(const T &a)
Definition: cpp11_fixes.h:19
__device__ T conj(T x)
Definition: cu_complex.h:226
static std::string to_string(T value)
Definition: cpp11_fixes.h:50
static T norm(const T &a)
Definition: cpp11_fixes.h:29