IsDefault.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SHIMS_ISDEFAULT_H_
36 #define _BLAZE_MATH_SHIMS_ISDEFAULT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <cmath>
44 #include <blaze/math/Accuracy.h>
45 #include <blaze/system/Inline.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // ISDEFAULT SHIM
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
76 template< typename Type >
77 BLAZE_ALWAYS_INLINE bool isDefault( const Type& v )
78 {
79  return v == Type();
80 }
81 //*************************************************************************************************
82 
83 
84 //*************************************************************************************************
96 BLAZE_ALWAYS_INLINE bool isDefault( float v )
97 {
98  return std::fabs( v ) <= accuracy;
99 }
101 //*************************************************************************************************
102 
103 
104 //*************************************************************************************************
116 BLAZE_ALWAYS_INLINE bool isDefault( double v )
117 {
118  return std::fabs( v ) <= accuracy;
119 }
121 //*************************************************************************************************
122 
123 
124 //*************************************************************************************************
136 BLAZE_ALWAYS_INLINE bool isDefault( long double v )
137 {
138  return std::fabs( v ) <= accuracy;
139 }
141 //*************************************************************************************************
142 
143 
144 //*************************************************************************************************
156 template< typename T >
157 BLAZE_ALWAYS_INLINE bool isDefault( const complex<T>& v )
158 {
159  return isDefault( real( v ) ) && isDefault( imag( v ) );
160 }
162 //*************************************************************************************************
163 
164 } // namespace blaze
165 
166 #endif
Computation accuracy for floating point data types.
const ImagExprTrait< MT >::Type imag(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the imaginary part of each single element of dm.
Definition: DMatImagExpr.h:920
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
const RealExprTrait< MT >::Type real(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the real part of each single element of dm.
Definition: DMatRealExpr.h:920
const Accuracy accuracy
Global Accuracy instance.The blaze::accuracy instance can be used wherever a floating point data type...
Definition: Accuracy.h:901
System settings for the inline keywords.