20 #include <pz_config.h> 23 #ifndef _USE_MATH_DEFINES 24 #define _USE_MATH_DEFINES 26 #endif // _USE_MATH_DEFINES 33 template <
int Num,
class T>
class TFad;
36 template <
typename Enumeration>
37 typename std::underlying_type<Enumeration>::type
as_integer(
const Enumeration value) {
38 return static_cast<typename std::underlying_type<Enumeration>::type
>(value);
67 std::is_integral<T>::value ||
68 std::is_floating_point<T>::value> { };
76 std::is_integral<T>::value ||
77 is_complex_or_floating_point<T>::value> { };
81 #define MAX( a, b ) ( (a) > (b) ? (a) : (b) ) 85 #define MIN( a, b ) ( (a) < (b) ? (a) : (b) ) 89 #define __PRETTY_FUNCTION__ __FILE__ 105 enum MOptype {
ESum,
EProd,
EDiv,
ESqrt,
EPow,
ECos,
ESin,
EAcos,
EAsin,
EAtan,
EExp,
ELog};
131 for(
int i=0; i<
gNumOp; i++) fCount[i] += other.
fCount[i];
137 for(
int i=0; i<
gNumOp; i++) fCount[i] -= other.
fCount[i];
143 for (
int i=0; i<
gNumOp; i++) fCount[i] = other.
fCount[i];
149 for(
int i=0; i<
gNumOp; i++) fCount[i] = 0 ;
153 void Print(std::ostream &out = std::cout)
const;
169 #ifdef REALlongdouble 170 typedef long double REAL;
171 #endif // REALlongdouble 172 #ifdef REALpzfpcounter 174 #endif // REALpzfpcounter 181 typedef double STATE;
182 #endif // STATEdouble 183 #ifdef STATElongdouble 184 typedef long double STATE;
185 #endif // STATElongdouble 187 typedef std::complex<float> STATE;
188 #endif // STATEcomplexf 190 typedef std::complex<double> STATE;
191 #endif //STATEcomplexd 192 #ifdef STATEcomplexld 193 typedef std::complex<long double> STATE;
194 #endif //STATEcomplexld 199 #define NOMINMAX // Preventing the redefinition of min and max as macros 206 return sqrt ((
double)__x);
212 return (
int)
fabs((
double) __x);
217 return sin((
double) __x);
222 return cos((
double) __x);
227 return atan((
double) __x);
235 std::complex <float> ret =
abs(__x);
239 fabs(std::complex <double> __x)
241 std::complex <double> ret =
abs(__x);
245 fabs(std::complex <long double> __x)
247 std::complex <long double> ret =
abs(__x);
264 #ifdef REALpzfpcounter 268 #endif //REALpzfpcounter 285 operator REAL()
const{
331 result.
fVal = fVal*oth;
339 result.
fVal = fVal/((REAL)oth);
405 return (fVal < sec.
fVal);
410 return (fVal > sec.
fVal);
415 return (fVal <= sec.
fVal);
420 return (fVal >= sec.
fVal);
425 return (fVal == sec.
fVal);
430 return (fVal != sec.
fVal);
622 return out << val.
fVal;
627 return out >> val.
fVal;
634 typedef std::numeric_limits< REAL >
dbl;
635 return (REAL)
pow(10,(-1 * (dbl::max_digits10- 5)));
639 typename std::enable_if< is_arithmetic_pz<T>::value,
int>::type* =
nullptr>
641 typedef std::numeric_limits< T >
dbl;
642 tol = (T)
pow(10,(-1 * (dbl::max_digits10- 5)));
646 typename std::enable_if<std::is_same<T,TPZFlopCounter>::value>::type* =
nullptr>
648 typedef std::numeric_limits< REAL >
dbl;
649 tol = (T)
pow(10,(-1 * (dbl::max_digits10- 5)));
653 template<
int Num,
typename T>
662 inline bool IsZero( T a ) {
670 return (
fabs( a ) < 1.e-12 );
678 return (
fabs( a ) < 1.e-10 );
680 return (
fabs( a ) < 1.e-12 );
686 return (
fabs( a ) < 1.e-6 );
688 return (
fabs( a ) < 1.e-6 );
692 inline bool IsZero( std::complex<long double> a ) {
694 return (
fabs( a ) < 1.e-12 );
696 return (
fabs( a ) < 1.e-16 );
700 inline bool IsZero( std::complex<double> a ) {
702 return (
fabs( a ) < 1.e-9 );
704 return (
fabs( a ) < 1.e-12 );
708 inline bool IsZero( std::complex<float> a ) {
710 return (
fabs( a ) < 1.e-5 );
712 return (
fabs( a ) < 1.e-7 );
724 inline const T&
Max(
const T &a,
const T &b ) {
725 return a > b ? a : b;
729 inline const T&
Min(
const T & a,
const T &b ) {
730 return a < b ? a : b;
739 #if (!defined(__cplusplus) || __cplusplus < 201103L) && (!defined(_MSC_VER) || _MSC_VER < 1900)// If we aren't using C++11. 748 #if defined(_MSC_VER) && _MSC_VER < 1900 // Microsoft Visual Studio < 2015 751 #define isnan(x) _isnan(x) static TPZCounter gCount
Containts the counter vector by operation performed.
TPZFlopCounter operator+(double val1, const TPZFlopCounter &val2)
Performs . Doesn't increments counters.
TPZCounter operator-(const TPZCounter &other)
TPZFlopCounter exp(const TPZFlopCounter &orig)
Returns the exponencial and increments the counter of the Exponencial.
TPZFlopCounter & operator*=(const TPZFlopCounter &oth)
Performs the product with oth value on own value and increments the counter of the products...
TPZFlopCounter atan2(const TPZFlopCounter &val1, const TPZFlopCounter &val2)
Returns the arc tangent in radians and increments the counter of the Arc Tangent. ATAN2 returns the ...
TPZFlopCounter operator+(const TPZFlopCounter &oth) const
Returns the sum with oth value and increments the counter of the sums.
TPZFlopCounter operator/(const double &oth) const
Returns the division between oth value and increments the counter of the divisions.
TPZFlopCounter asin(const TPZFlopCounter &orig)
Returns the arc sine in radians and increments the counter of the Arc Sine.
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
bool operator<(const REAL &val) const
bool operator<=(const REAL &val) const
TPZFlopCounter sqrt(const TPZFlopCounter &orig)
Returns the square root of the value and increments the counter of the square root.
float fabs(std::complex< float > __x)
This is the type of floating point number PZ will use.
TPZFlopCounter operator*(const REAL &oth) const
Returns the product with the oth value and increments the counter of the products.
TPZFlopCounter operator-(const TPZFlopCounter &oth) const
Returns the difference with oth value and increments the counter of the sums.
bool operator<(const TPZFlopCounter &sec) const
Compares the values and doesn't increments the counters.
bool operator>=(const TPZFlopCounter &sec) const
Compares the values and doesn't increments the counters.
bool operator>(const TPZFlopCounter &sec) const
Compares the values and doesn't increments the counters.
std::underlying_type< Enumeration >::type as_integer(const Enumeration value)
TPZFlopCounter operator/(const TPZFlopCounter &oth) const
Returns the division between oth value and increments the counter of the divisions.
TPZFlopCounter & operator-=(const TPZFlopCounter &oth)
Performs the diference with oth value on own value and increments the counter of the sums...
TPZFlopCounter log10(const TPZFlopCounter &orig)
Returns the decimal logarithm and increment the counter of the logarithm.
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
REAL val(STATE &number)
Returns value of the variable.
bool operator>(const REAL &val) const
std::istream & operator>>(std::istream &out, TPZFlopCounter &val)
Implements to read (input) only the floating point value.
TPZFlopCounter(const double &val)
bool operator>=(const REAL &val) const
TPZFlopCounter operator/(double val1, const TPZFlopCounter &val2)
Performs . Doesn't increments counters.
TPZFlopCounter operator-(double val1, const TPZFlopCounter &val2)
Performs . Doesn't increments counters.
const int gNumOp
Number of type of the operations actually counted.
bool operator<=(const TPZFlopCounter &sec) const
Compares the values and doesn't increments the counters.
const T & Max(const T &a, const T &b)
Returns the maximum value between a and b.
TPZFlopCounter operator+() const
Returns the current floating point value and doesn't increments the counters.
int gPrintLevel
Extern variable to control level of printting (priority print?)
TPZFlopCounter fabsFlop(const TPZFlopCounter &orig)
Returns the absolute value and doesn't increments the counters.
std::numeric_limits< REAL > dbl
bool operator!=(const TPZFlopCounter &sec) const
Compares the values and doesn't increments the counters.
TPZFlopCounter & operator+=(const TPZFlopCounter &oth)
Performs the sum with oth value on own value and increments the counter of the sums.
TPZFlopCounter sin(const TPZFlopCounter &orig)
Returns the sine in radians and increments the counter of the sine.
REAL fVal
Floating point value.
bool operator==(const REAL &val) const
const T & Min(const T &a, const T &b)
Returns the minimum value between a and b.
TPZFlopCounter atan(const TPZFlopCounter &orig)
Returns the arc tangent in radians and increments the counter of the Arc Tangent. ...
TPZFlopCounter & operator/=(const TPZFlopCounter &oth)
Performs the division between oth value on own value and increments the counter of the divisions...
TPZCounter & operator-=(const TPZCounter &other)
TPZFlopCounter operator*(const TPZFlopCounter &oth) const
Returns the product with the oth value and increments the counter of the products.
TPZFlopCounter acos(const TPZFlopCounter &orig)
Returns the arc cosine in radians and increments the counter of the Arc Cosine.
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
Implements a counter by operations. Common.
std::ostream & operator<<(std::ostream &out, const TPZCounter &count)
Re-implements << operator to show the counter (count) data.
TPZFlopCounter operator*(double val1, const TPZFlopCounter &val2)
Performs . Doesn't increments counters.
TPZCounter()
Counter constructor.
This class implements floating point number associated with a counter of the operations performed wit...
bool operator==(const TPZFlopCounter &sec) const
Compares the values and doesn't increments the counters.
TPZCounter & copy(const TPZCounter &other)
MOptype
Types of operations to be counted.
REAL ZeroTolerance()
Returns the tolerance to Zero value. Actually: .
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
Defines functions to help with invalid arithmetic operations.
TPZFlopCounter operator-() const
Returns value with signal changed of its floating point value and increments the counter of the sums...
TPZFlopCounter log(const TPZFlopCounter &orig)
Returns the natural logarithm and increment the counter of the logarithm.
TPZCounter & operator+=(const TPZCounter &other)