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 #include <blaze/util/Complex.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // ISDEFAULT SHIM
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
78 template< typename Type >
79 BLAZE_ALWAYS_INLINE bool isDefault( const Type& v ) noexcept( IsBuiltin<Type>::value )
80 {
81  return v == Type();
82 }
83 //*************************************************************************************************
84 
85 
86 //*************************************************************************************************
98 BLAZE_ALWAYS_INLINE bool isDefault( float v ) noexcept
99 {
100  return std::fabs( v ) <= accuracy;
101 }
103 //*************************************************************************************************
104 
105 
106 //*************************************************************************************************
118 BLAZE_ALWAYS_INLINE bool isDefault( double v ) noexcept
119 {
120  return std::fabs( v ) <= accuracy;
121 }
123 //*************************************************************************************************
124 
125 
126 //*************************************************************************************************
138 BLAZE_ALWAYS_INLINE bool isDefault( long double v ) noexcept
139 {
140  return std::fabs( v ) <= accuracy;
141 }
143 //*************************************************************************************************
144 
145 
146 //*************************************************************************************************
158 template< typename T >
159 BLAZE_ALWAYS_INLINE bool isDefault( const complex<T>& v ) noexcept( IsBuiltin<T>::value )
160 {
161  return isDefault( real( v ) ) && isDefault( imag( v ) );
162 }
164 //*************************************************************************************************
165 
166 } // namespace blaze
167 
168 #endif
Computation accuracy for floating point data types.
const DMatForEachExpr< MT, Imag, SO > imag(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the imaginary part of each single element of dm.
Definition: DMatForEachExpr.h:1251
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
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 DMatForEachExpr< MT, Real, SO > real(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the real part of each single element of dm.
Definition: DMatForEachExpr.h:1223
Compile time check for built-in data types.This type trait tests whether or not the given template pa...
Definition: IsBuiltin.h:75
const Accuracy accuracy
Global Accuracy instance.The blaze::accuracy instance can be used wherever a floating point data type...
Definition: Accuracy.h:901
Header file for the IsBuiltin type trait.
Header file for the complex data type.
System settings for the inline keywords.