Sign.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SHIMS_SIGN_H_
36 #define _BLAZE_MATH_SHIMS_SIGN_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/util/EnableIf.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // SIGN SHIM
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
67 template< typename T, typename = EnableIf_t< IsBuiltin_v<T> > >
68 inline constexpr T sign( T a ) noexcept
69 {
70  return ( IsSigned_v<T> || IsFloatingPoint_v<T> )
71  ?( T(0) < a ) - ( a < T(0) )
72  :( T(0) < a );
73 }
74 //*************************************************************************************************
75 
76 } // namespace blaze
77 
78 #endif
decltype(auto) sign(const DenseMatrix< MT, SO > &dm)
Applies the sign() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1181
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the IsFloatingPoint type trait.
Header file for the EnableIf class template.
Header file for the IsSigned type trait.
Header file for the IsBuiltin type trait.