Blaze 3.9
Loading...
Searching...
No Matches
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>
48#include <blaze/system/Inline.h>
49#include <blaze/util/Complex.h>
50#include <blaze/util/EnableIf.h>
52
53
54namespace blaze {
55
56//=================================================================================================
57//
58// ISDEFAULT SHIM
59//
60//=================================================================================================
61
62//*************************************************************************************************
99template< RelaxationFlag RF // Relaxation flag
100 , typename Type // Type of the given value/object
103{
104 return v == Type();
105}
106//*************************************************************************************************
107
108
109//*************************************************************************************************
121template< RelaxationFlag RF > // Relaxation flag
122BLAZE_ALWAYS_INLINE bool isDefault( float v ) noexcept
123{
124 if( RF == relaxed )
125 return std::fabs( v ) <= accuracy;
126 else
127 return v == 0.0F;
128}
130//*************************************************************************************************
131
132
133//*************************************************************************************************
145template< RelaxationFlag RF > // Relaxation flag
146BLAZE_ALWAYS_INLINE bool isDefault( double v ) noexcept
147{
148 if( RF == relaxed )
149 return std::fabs( v ) <= accuracy;
150 else
151 return v == 0.0;
152}
154//*************************************************************************************************
155
156
157//*************************************************************************************************
169template< RelaxationFlag RF > // Relaxation flag
170BLAZE_ALWAYS_INLINE bool isDefault( long double v ) noexcept
171{
172 if( RF == relaxed )
173 return std::fabs( v ) <= accuracy;
174 else
175 return v == 0.0L;
176}
178//*************************************************************************************************
179
180
181//*************************************************************************************************
193template< RelaxationFlag RF // Relaxation flag
194 , typename T > // Value type of the complex number
195BLAZE_ALWAYS_INLINE bool isDefault( const complex<T>& v ) noexcept( IsBuiltin_v<T> )
196{
197 return isDefault<RF>( real( v ) ) && isDefault<RF>( imag( v ) );
198}
200//*************************************************************************************************
201
202
203//*************************************************************************************************
240template< typename Type > // Type of the given value/object
242{
243 return isDefault<relaxed>( v );
244}
245//*************************************************************************************************
246
247} // namespace blaze
248
249#endif
Computation accuracy for floating point data types.
Header file for the complex data type.
Header file for the EnableIf class template.
Header file for the IsBuiltin type trait.
Header file for the IsSIMDPack type trait.
Header file for the IsScalar type trait.
Header file for the relaxation flag enumeration.
decltype(auto) real(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the real part of each single element of dm.
Definition DMatMapExpr.h:1529
decltype(auto) imag(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the imaginary part of each single element of dm.
Definition DMatMapExpr.h:1557
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition DiagonalMatrix.h:169
constexpr bool IsSIMDPack_v
Auxiliary variable template for the IsSIMDPack type trait.
Definition IsSIMDPack.h:157
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition RelaxationFlag.h:66
constexpr Accuracy accuracy
Global Accuracy instance.
Definition Accuracy.h:907
@ relaxed
Flag for relaxed semantics.
Definition RelaxationFlag.h:68
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition Inline.h:85
constexpr bool IsBuiltin_v
Auxiliary variable template for the IsBuiltin type trait.
Definition IsBuiltin.h:95
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
System settings for the inline keywords.