NeoPZ
pzextractval.h
Go to the documentation of this file.
1 //
2 // ExtractVal.h
3 // PZ
4 //
5 // Created by Francisco Orlandini on 10/21/15.
6 //
7 //
8 
9 #ifndef ExtractVal_h
10 #define ExtractVal_h
11 
12 #include "pzreal.h"
13 
14 #ifdef _AUTODIFF
15 #include "tfad.h"
16 #endif
17 
19 public:
20 
21  static REAL val(const int number) {
22  return (REAL) number;
23  }
24 
25  static REAL val(const int64_t number) {
26  return (REAL) number;
27  }
28 
29  static REAL val(const float number) {
30  return (REAL) number;
31  }
32 
33  static REAL val(const double number) {
34  return (REAL) number;
35  }
36 
37  static REAL val(const long double number) {
38  return (REAL) number;
39  }
40 
41  static REAL val(const std::complex<float> number) {
42  return (REAL) number.real();
43  }
44 
45  static REAL val(const std::complex<double> number) {
46  return (REAL) number.real();
47  }
48 
49  static REAL val(const std::complex<long double> number) {
50  return (REAL) number.real();
51  }
52 
53  template <class T>
54  static REAL val(const T number) {
55  return TPZExtractVal::val(number.val()); // recursively downgrading until REAL type is reached
56  }
57 
58  static int& ref(int &number) {
59  return number;
60  }
61 
62  static int64_t& ref(int64_t &number) {
63  return number;
64  }
65 
66  static float& ref(float &number) {
67  return number;
68  }
69 
70  static double& ref(double &number) {
71  return number;
72  }
73 
74  static long double& ref(long double &number) {
75  return number;
76  }
77 
78 #ifdef _AUTODIFF
79 
80  template <int Num, class T>
81  static typename TFad<Num,T>::arithmetic_type& ref(TFad<Num,T> &number) {
82  return TPZExtractVal::ref(number.val());
83  }
84 
85 #endif
86 
87  template<class T>
88  static bool IsZero(const T & a) {
90  }
91 
92 };
93 
94 
95 #endif /* ExtractVal_h */
static int & ref(int &number)
Definition: pzextractval.h:58
static REAL val(const double number)
Definition: pzextractval.h:33
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
Definition: pzreal.h:668
GetArithmeticType< T >::type arithmetic_type
Definition: tfad.h:67
static REAL val(const std::complex< float > number)
Definition: pzextractval.h:41
Definition: tfad.h:64
static bool IsZero(const T &a)
Definition: pzextractval.h:88
static REAL val(const long double number)
Definition: pzextractval.h:37
static REAL val(const int64_t number)
Definition: pzextractval.h:25
static REAL val(const int number)
Definition: pzextractval.h:21
static REAL val(const std::complex< double > number)
Definition: pzextractval.h:45
static long double & ref(long double &number)
Definition: pzextractval.h:74
static REAL val(const std::complex< long double > number)
Definition: pzextractval.h:49
static REAL val(const float number)
Definition: pzextractval.h:29
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
static REAL val(const T number)
Definition: pzextractval.h:54
static int64_t & ref(int64_t &number)
Definition: pzextractval.h:62
const T & val() const
Definition: tfad.h:89
static float & ref(float &number)
Definition: pzextractval.h:66
static double & ref(double &number)
Definition: pzextractval.h:70