71#define SIMDBYTE_TRUE (::simd::Byte(~0))
72#define SIMDSIGNEDBYTE_TRUE (::simd::SignedByte(~0))
73#define SIMDWORD_TRUE (::simd::Word(~0))
74#define SIMDSHORT_TRUE (::simd::Short(~0))
75#define SIMDINT_TRUE (::simd::Int(~0))
76#define SIMDLONG_TRUE (::simd::Long(~0))
77#define SIMDFLOAT_TRUE (::simd::internal::bit_cast<::simd::Float>(SIMDINT_TRUE))
78#define SIMDDOUBLE_TRUE \
79 (::simd::internal::bit_cast<::simd::Double>(SIMDLONG_TRUE))
81#define SIMDBYTE_MIN (::std::numeric_limits<Byte>::lowest())
82#define SIMDSIGNEDBYTE_MIN (::std::numeric_limits<SignedByte>::lowest())
83#define SIMDWORD_MIN (::std::numeric_limits<Word>::lowest())
84#define SIMDSHORT_MIN (::std::numeric_limits<Short>::lowest())
85#define SIMDINT_MIN (::std::numeric_limits<Int>::lowest())
86#define SIMDLONG_MIN (::std::numeric_limits<Long>::lowest())
87#define SIMDFLOAT_MIN (::std::numeric_limits<Float>::lowest())
88#define SIMDDOUBLE_MIN (::std::numeric_limits<Double>::lowest())
90#define SIMDBYTE_MAX (::std::numeric_limits<Byte>::max())
91#define SIMDSIGNEDBYTE_MAX (::std::numeric_limits<SignedByte>::max())
92#define SIMDWORD_MAX (::std::numeric_limits<Word>::max())
93#define SIMDSHORT_MAX (::std::numeric_limits<Short>::max())
94#define SIMDINT_MAX (::std::numeric_limits<Int>::max())
95#define SIMDLONG_MAX (::std::numeric_limits<Long>::max())
96#define SIMDFLOAT_MAX (::std::numeric_limits<Float>::max())
97#define SIMDDOUBLE_MAX (::std::numeric_limits<Double>::max())
100#define MAX_POS_FLOAT_CONVERTIBLE_TO_INT32 2147483520.0f
102#define MAX_POS_FLOAT_CONVERTIBLE_TO_INT64 9223371487098961920.0f
104#define MAX_POS_DOUBLE_CONVERTIBLE_TO_INT32 2147483647.0
106#define MAX_POS_DOUBLE_CONVERTIBLE_TO_INT64 9223372036854774784.0
147 static constexpr SIMD_INLINE
const char *name() {
return "Byte"; }
148 static constexpr SIMD_INLINE
const char *format() {
return "u"; }
149 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%u "; }
150 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%02x "; }
151 static constexpr SIMD_INLINE
Byte trueval() {
return SIMDBYTE_TRUE; }
152 using NextLargerType =
Word;
153 using UnsignedType =
Byte;
161 static constexpr SIMD_INLINE
const char *name() {
return "SignedByte"; }
162 static constexpr SIMD_INLINE
const char *format() {
return "d"; }
163 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%d "; }
164 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%02x "; }
165 static constexpr SIMD_INLINE
SignedByte trueval()
167 return SIMDSIGNEDBYTE_TRUE;
169 using NextLargerType =
Short;
170 using UnsignedType =
Byte;
178 static constexpr SIMD_INLINE
const char *name() {
return "Word"; }
179 static constexpr SIMD_INLINE
const char *format() {
return "u"; }
180 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%u "; }
181 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%04x "; }
182 static constexpr SIMD_INLINE
Word trueval() {
return SIMDWORD_TRUE; }
183 using NextLargerType =
Int;
184 using UnsignedType =
Word;
185 using SignedType =
Short;
186 using IntegerType =
Short;
190struct TypeInfo<
Short>
192 static constexpr SIMD_INLINE
const char *name() {
return "Short"; }
193 static constexpr SIMD_INLINE
const char *format() {
return "d"; }
194 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%d "; }
195 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%04x "; }
196 static constexpr SIMD_INLINE
Short trueval() {
return SIMDSHORT_TRUE; }
197 using NextLargerType =
Int;
198 using UnsignedType =
Word;
199 using SignedType =
Short;
200 using IntegerType =
Short;
206 static constexpr SIMD_INLINE
const char *name() {
return "Int"; }
207 static constexpr SIMD_INLINE
const char *format() {
return "d"; }
208 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%d "; }
209 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%08x "; }
210 static constexpr SIMD_INLINE
Int trueval() {
return SIMDINT_TRUE; }
211 using NextLargerType =
Long;
212 using UnsignedType = uint32_t;
213 using SignedType =
Int;
214 using IntegerType =
Int;
220 static constexpr SIMD_INLINE
const char *name() {
return "Long"; }
221 static constexpr SIMD_INLINE
const char *format() {
return "ld"; }
222 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%ld "; }
223 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%016lx "; }
224 static constexpr SIMD_INLINE
Long trueval() {
return SIMDLONG_TRUE; }
225 using NextLargerType =
Long;
226 using UnsignedType = uint64_t;
227 using SignedType =
Long;
228 using IntegerType =
Long;
232struct TypeInfo<
Float>
234 static constexpr SIMD_INLINE
const char *name() {
return "Float"; }
235 static constexpr SIMD_INLINE
const char *format() {
return ".9g"; }
236 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%.9g "; }
237 static SIMD_INLINE
Float trueval() {
return SIMDFLOAT_TRUE; }
238 using NextLargerType =
Double;
239 using UnsignedType =
Float;
240 using SignedType =
Float;
241 using IntegerType =
Int;
247 static constexpr SIMD_INLINE
const char *name() {
return "Double"; };
248 static constexpr SIMD_INLINE
const char *format() {
return ".17g"; };
249 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%.17g "; };
250 static SIMD_INLINE
Double trueval() {
return SIMDDOUBLE_TRUE; }
251 using NextLargerType =
Double;
252 using UnsignedType =
Double;
253 using SignedType =
Double;
254 using IntegerType =
Long;
267 static constexpr SIMD_INLINE
const char *
name()
269 return internal::types::TypeInfo<T>::name();
272 static constexpr SIMD_INLINE
const char *
format()
274 return internal::types::TypeInfo<T>::format();
280 return internal::types::TypeInfo<T>::defaultFormat();
285 return internal::types::TypeInfo<T>::hexFormat();
292 static constexpr bool isSigned = std::is_signed<T>::value;
298 static constexpr bool isInteger = std::is_integral<T>::value;
309 static constexpr SIMD_INLINE T
min()
311 return std::numeric_limits<T>::lowest();
317 static constexpr SIMD_INLINE T
max() {
return std::numeric_limits<T>::max(); }
321 return internal::types::TypeInfo<T>::trueval();
328 using UnsignedType =
typename internal::types::TypeInfo<T>::UnsignedType;
331 using SignedType =
typename internal::types::TypeInfo<T>::SignedType;
334 using IntegerType =
typename internal::types::TypeInfo<T>::IntegerType;
360 Format(
int fieldWidth = -1,
int precision = -1)
362 char fieldWidthStr[16], precisionStr[16];
364 sprintf(fieldWidthStr,
"%d", fieldWidth);
366 strcpy(fieldWidthStr,
"");
368 sprintf(precisionStr,
".%d", precision);
370 strcpy(precisionStr,
"");
376 sprintf(
format,
"%%%s%s%s", fieldWidthStr, precisionStr,
400 Decimal(T value,
int fieldWidth = -1,
int precision = -1)
402 sprintf(
str,
Format<T>(fieldWidth, precision).format, value);
459template <
bool AT_LOWER_LIMIT,
size_t LOWER_LIMIT_INCLUSIVE,
460 size_t UPPER_LIMIT_EXCLUSIVE>
464template <
size_t IMM,
size_t SIZE>
466 :
public Range<(IMM & (SIZE - 1)) == 0,
468 (IMM & ~(SIZE - 1)) + SIZE>
float Float
Single-precision floating point number (32-bit)
Definition types.H:56
int16_t Short
Signed 16-bit integer.
Definition types.H:53
int32_t Int
Signed 32-bit integer.
Definition types.H:54
uint16_t Word
Unsigned 16-bit integer.
Definition types.H:52
int64_t Long
Signed 64-bit integer.
Definition types.H:55
uint8_t Byte
Unsigned 8-bit integer.
Definition types.H:50
double Double
Double-precision floating point number (64-bit)
Definition types.H:57
int8_t SignedByte
Signed 8-bit integer.
Definition types.H:51
SortSlope
Used to indicate the direction of a sort function.
Definition types.H:115
Namespace for T-SIMD.
Definition time_measurement.H:161
typename internal::dont_deduce< T >::type dont_deduce
Helper type to prevent template argument deduction.
Definition types.H:427
Class for formatting SIMD types as decimal numbers.
Definition types.H:390
Decimal(T value, int fieldWidth=-1, int precision=-1)
Constructor.
Definition types.H:400
char str[256]
The formatted string.
Definition types.H:391
Type information for SIMD types.
Definition types.H:265
typename internal::types::TypeInfo< T >::IntegerType IntegerType
The signed integer type of the same size (e.g. SignedByte for Byte, Int for Float)
Definition types.H:334
static constexpr bool isFloatingPoint
Whether the type is a floating point type.
Definition types.H:304
static constexpr T max()
Returns the maximum value of the type.
Definition types.H:317
static constexpr bool isSigned
Whether the type is signed.
Definition types.H:292
typename internal::types::TypeInfo< T >::NextLargerType NextLargerType
The next larger type (e.g. Word for Byte), or the same type if there is no larger type.
Definition types.H:325
static constexpr T trueval()
Returns a value where all bits are 1.
Definition types.H:319
static constexpr const char * format()
Returns the format string for printf (e.g. "d" for Int)
Definition types.H:272
typename internal::types::TypeInfo< T >::SignedType SignedType
The signed type (e.g. SignedByte for Byte), or the same type if there is no signed type.
Definition types.H:331
static constexpr const char * defaultFormat()
Returns the default format string for printf (e.g. "%d " for Int)
Definition types.H:278
static constexpr T min()
Returns the minimum value of the type.
Definition types.H:309
static constexpr const char * name()
Returns the name of the type (e.g. "Int" for Int)
Definition types.H:267
typename internal::types::TypeInfo< T >::UnsignedType UnsignedType
The unsigned type (e.g. Byte for SignedByte), or the same type if there is no unsigned type.
Definition types.H:328
static constexpr bool isInteger
Whether the type is an integer.
Definition types.H:298
static constexpr const char * hexFormat()
Returns the hex format string for printf (e.g. "%08x " for Int)
Definition types.H:283