22 #if defined( LVARRAY_USE_CUDA ) 23 #include <cuda_fp16.h> 35 template<
typename T >
41 static constexpr T
lowest = std::numeric_limits< T >::lowest();
45 static constexpr T
epsilon = std::numeric_limits< T >::epsilon();
47 static constexpr T
round_error = std::numeric_limits< T >::round_error();
49 static constexpr T
infinity = std::numeric_limits< T >::infinity();
51 static constexpr T
quiet_NaN = std::numeric_limits< T >::quiet_NaN();
53 static constexpr T
signaling_NaN = std::numeric_limits< T >::signaling_NaN();
55 static constexpr T
denorm_min = std::numeric_limits< T >::denorm_min();
58 #if defined( LVARRAY_USE_CUDA ) 67 static constexpr
float min = 1.0 / 16384;
69 static constexpr
float lowest = -65504;
71 static constexpr
float max = 65504;
73 static constexpr
float epsilon = 1.0 / 1024;
75 static constexpr
float denorm_min = 1.0 / 16777216;
90 template<
typename T >
113 template<
typename T,
typename U >
114 constexpr
bool sameSignedness = ( std::is_signed< T >::value && std::is_signed< U >::value ) ||
115 ( std::is_unsigned< T >::value && std::is_unsigned< U >::value );
122 template<
typename INPUT,
typename OUTPUT >
124 (
sizeof( INPUT ) ==
sizeof( OUTPUT ) && sameSignedness< INPUT, OUTPUT > );
134 template<
typename OUTPUT,
typename INPUT >
135 std::enable_if_t< internal::canEasilyConvert< INPUT, OUTPUT >, OUTPUT >
139 static_assert( std::is_integral< INPUT >::value,
"INPUT must be an integral type." );
140 static_assert( std::is_integral< OUTPUT >::value,
"OUTPUT must be an integral type." );
143 return static_cast< OUTPUT
>(input);
152 template<
typename OUTPUT,
typename INPUT >
153 std::enable_if_t< !internal::canEasilyConvert< INPUT, OUTPUT > &&
154 std::is_unsigned< INPUT >::value,
159 static_assert( std::is_integral< INPUT >::value,
"INPUT must be an integral type." );
160 static_assert( std::is_integral< OUTPUT >::value,
"OUTPUT must be an integral type." );
164 return static_cast< OUTPUT
>( input );
173 template<
typename OUTPUT,
typename INPUT >
174 std::enable_if_t< !internal::canEasilyConvert< INPUT, OUTPUT > &&
175 !std::is_unsigned< INPUT >::value,
180 static_assert( std::is_integral< INPUT >::value,
"INPUT must be an integral type." );
181 static_assert( std::is_integral< OUTPUT >::value,
"OUTPUT must be an integral type." );
187 using ConditionallyUnsigned = std::conditional_t< std::is_unsigned< OUTPUT >::value, std::make_unsigned_t< INPUT >, INPUT >;
190 return static_cast< OUTPUT
>( input );
static constexpr T min
The smallest finite value T can hold.
Definition: limits.hpp:39
#define LVARRAY_ERROR_IF_LT(lhs, rhs)
Raise a hard error if one value compares less than the other.
Definition: Macros.hpp:417
static constexpr T signaling_NaN
A signaling NaN (if T is a floating point).
Definition: limits.hpp:53
LVARRAY_HOST_DEVICE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > min(T const a, T const b)
Definition: math.hpp:358
static constexpr T infinity
A positive infinity value (if T is a floating point).
Definition: limits.hpp:49
#define LVARRAY_ERROR_IF_GT(lhs, rhs)
Raise a hard error if one value compares greater than the other.
Definition: Macros.hpp:353
static constexpr T denorm_min
The smallest positive subnormal value (if T is a floating point).
Definition: limits.hpp:55
constexpr bool sameSignedness
True iff.
Definition: limits.hpp:114
constexpr bool canEasilyConvert
True iff.
Definition: limits.hpp:123
static constexpr T round_error
The maximum rounding error (if T is a floating point).
Definition: limits.hpp:47
The same as NumericLimits except the entries are not static or constexpr.
Definition: limits.hpp:91
The top level namespace.
Definition: Array.hpp:24
A wrapper for the std::numeric_limits< T > member functions, this allows their values to be used on d...
Definition: limits.hpp:36
static constexpr T quiet_NaN
A quiet NaN (if T is a floating point).
Definition: limits.hpp:51
Contains a bunch of macro definitions.
LVARRAY_HOST_DEVICE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
Definition: math.hpp:311
static constexpr T lowest
The lowest finite value T can hold.
Definition: limits.hpp:41
static constexpr T epsilon
The difference between 1.0 and the next representable value (if T is floating point).
Definition: limits.hpp:45
std::enable_if_t< internal::canEasilyConvert< INPUT, OUTPUT >, OUTPUT > constexpr LVARRAY_HOST_DEVICE integerConversion(INPUT input)
Definition: limits.hpp:137
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
Definition: Macros.hpp:549
static constexpr T max
The largest finite value T can hold.
Definition: limits.hpp:43