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;
160 static constexpr SIMD_INLINE
const char *name() {
return "SignedByte"; }
161 static constexpr SIMD_INLINE
const char *format() {
return "d"; }
162 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%d "; }
163 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%02x "; }
164 static constexpr SIMD_INLINE
SignedByte trueval()
166 return SIMDSIGNEDBYTE_TRUE;
168 using NextLargerType =
Short;
169 using UnsignedType =
Byte;
176 static constexpr SIMD_INLINE
const char *name() {
return "Word"; }
177 static constexpr SIMD_INLINE
const char *format() {
return "u"; }
178 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%u "; }
179 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%04x "; }
180 static constexpr SIMD_INLINE
Word trueval() {
return SIMDWORD_TRUE; }
181 using NextLargerType =
Int;
182 using UnsignedType =
Word;
183 using SignedType =
Short;
187struct TypeInfo<
Short>
189 static constexpr SIMD_INLINE
const char *name() {
return "Short"; }
190 static constexpr SIMD_INLINE
const char *format() {
return "d"; }
191 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%d "; }
192 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%04x "; }
193 static constexpr SIMD_INLINE
Short trueval() {
return SIMDSHORT_TRUE; }
194 using NextLargerType =
Int;
195 using UnsignedType =
Word;
196 using SignedType =
Short;
202 static constexpr SIMD_INLINE
const char *name() {
return "Int"; }
203 static constexpr SIMD_INLINE
const char *format() {
return "d"; }
204 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%d "; }
205 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%08x "; }
206 static constexpr SIMD_INLINE
Int trueval() {
return SIMDINT_TRUE; }
207 using NextLargerType =
Long;
208 using UnsignedType = uint32_t;
209 using SignedType =
Int;
215 static constexpr SIMD_INLINE
const char *name() {
return "Long"; }
216 static constexpr SIMD_INLINE
const char *format() {
return "ld"; }
217 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%ld "; }
218 static constexpr SIMD_INLINE
const char *hexFormat() {
return "%016lx "; }
219 static constexpr SIMD_INLINE
Long trueval() {
return SIMDLONG_TRUE; }
220 using NextLargerType =
Long;
221 using UnsignedType = uint64_t;
222 using SignedType =
Long;
226struct TypeInfo<
Float>
228 static constexpr SIMD_INLINE
const char *name() {
return "Float"; }
229 static constexpr SIMD_INLINE
const char *format() {
return ".9g"; }
230 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%.9g "; }
231 static SIMD_INLINE
Float trueval() {
return SIMDFLOAT_TRUE; }
232 using NextLargerType =
Double;
233 using UnsignedType =
Float;
234 using SignedType =
Float;
240 static constexpr SIMD_INLINE
const char *name() {
return "Double"; };
241 static constexpr SIMD_INLINE
const char *format() {
return ".17g"; };
242 static constexpr SIMD_INLINE
const char *defaultFormat() {
return "%.17g "; };
243 static SIMD_INLINE
Double trueval() {
return SIMDDOUBLE_TRUE; }
244 using NextLargerType =
Double;
245 using UnsignedType =
Double;
246 using SignedType =
Double;
259 static constexpr SIMD_INLINE
const char *
name()
261 return internal::types::TypeInfo<T>::name();
264 static constexpr SIMD_INLINE
const char *
format()
266 return internal::types::TypeInfo<T>::format();
272 return internal::types::TypeInfo<T>::defaultFormat();
277 return internal::types::TypeInfo<T>::hexFormat();
284 static constexpr bool isSigned = std::is_signed<T>::value;
290 static constexpr bool isInteger = std::is_integral<T>::value;
301 static constexpr SIMD_INLINE T
min()
303 return std::numeric_limits<T>::lowest();
309 static constexpr SIMD_INLINE T
max() {
return std::numeric_limits<T>::max(); }
313 return internal::types::TypeInfo<T>::trueval();
320 using UnsignedType =
typename internal::types::TypeInfo<T>::UnsignedType;
323 using SignedType =
typename internal::types::TypeInfo<T>::SignedType;
349 Format(
int fieldWidth = -1,
int precision = -1)
351 char fieldWidthStr[16], precisionStr[16];
353 sprintf(fieldWidthStr,
"%d", fieldWidth);
355 strcpy(fieldWidthStr,
"");
357 sprintf(precisionStr,
".%d", precision);
359 strcpy(precisionStr,
"");
365 sprintf(
format,
"%%%s%s%s", fieldWidthStr, precisionStr,
389 Decimal(T value,
int fieldWidth = -1,
int precision = -1)
391 sprintf(
str,
Format<T>(fieldWidth, precision).format, value);
448template <
bool AT_LOWER_LIMIT,
size_t LOWER_LIMIT_INCLUSIVE,
449 size_t UPPER_LIMIT_EXCLUSIVE>
453template <
size_t IMM,
size_t SIZE>
455 :
public Range<(IMM & (SIZE - 1)) == 0,
457 (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:416
Class for formatting SIMD types as decimal numbers.
Definition types.H:379
Decimal(T value, int fieldWidth=-1, int precision=-1)
Constructor.
Definition types.H:389
char str[256]
The formatted string.
Definition types.H:380
Type information for SIMD types.
Definition types.H:257
static constexpr bool isFloatingPoint
Whether the type is a floating point type.
Definition types.H:296
static constexpr T max()
Returns the maximum value of the type.
Definition types.H:309
static constexpr bool isSigned
Whether the type is signed.
Definition types.H:284
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:317
static constexpr T trueval()
Returns a value where all bits are 1.
Definition types.H:311
static constexpr const char * format()
Returns the format string for printf (e.g. "d" for Int)
Definition types.H:264
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:323
static constexpr const char * defaultFormat()
Returns the default format string for printf (e.g. "%d " for Int)
Definition types.H:270
static constexpr T min()
Returns the minimum value of the type.
Definition types.H:301
static constexpr const char * name()
Returns the name of the type (e.g. "Int" for Int)
Definition types.H:259
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:320
static constexpr bool isInteger
Whether the type is an integer.
Definition types.H:290
static constexpr const char * hexFormat()
Returns the hex format string for printf (e.g. "%08x " for Int)
Definition types.H:275