Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
math
shims
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
>
44
#include <
blaze/util/typetraits/IsIntegral.h
>
45
#include <
blaze/util/typetraits/IsSigned.h
>
46
47
48
namespace
blaze {
49
50
//=================================================================================================
51
//
52
// SIGN SHIM
53
//
54
//=================================================================================================
55
56
//*************************************************************************************************
66
template
<
typename
T,
typename
= EnableIf_t< IsIntegral_v<T> > >
67
constexpr
T
sign
( T a )
noexcept
68
{
69
return
(
IsSigned_v<T>
)
70
? ( T(0) < a ) - ( a < T(0) )
71
: ( T(0) < a );
72
}
73
//*************************************************************************************************
74
75
76
//*************************************************************************************************
87
constexpr
float
sign
(
float
a )
noexcept
88
{
89
if
( 0.0F < a )
return
1.0F;
90
else
if
( a < 0.0F )
return
-1.0F;
91
else
return
a;
92
}
93
//*************************************************************************************************
94
95
96
//*************************************************************************************************
107
constexpr
double
sign
(
double
a )
noexcept
108
{
109
if
( 0.0 < a )
return
1.0;
110
else
if
( a < 0.0 )
return
-1.0;
111
else
return
a;
112
}
113
//*************************************************************************************************
114
115
116
//*************************************************************************************************
127
constexpr
long
double
sign
(
long
double
a )
noexcept
128
{
129
if
( 0.0L < a )
return
1.0L;
130
else
if
( a < 0.0L )
return
-1.0L;
131
else
return
a;
132
}
133
//*************************************************************************************************
134
135
}
// namespace blaze
136
137
#endif
EnableIf.h
Header file for the EnableIf class template.
IsIntegral.h
Header file for the IsIntegral type trait.
IsSigned.h
Header file for the IsSigned type trait.
blaze::sign
decltype(auto) sign(const DenseMatrix< MT, SO > &dm)
Applies the sign() function to each single element of the dense matrix dm.
Definition
DMatMapExpr.h:1324
blaze::IsSigned_v
constexpr bool IsSigned_v
Auxiliary variable template for the IsSigned type trait.
Definition
IsSigned.h:97
Generated by
1.18.0