9#include <stratax/core/dtypes/Types.hpp>
11namespace stratax::core {
25namespace dtype_detail {
39#define STRATAX_DEFINE_DTYPE_TRAITS(TYPE, KIND, NAME) \
41 struct DTypeTraitsImpl<TYPE> \
44 static constexpr DTypeKind kind = DTypeKind::KIND; \
45 static constexpr std::size_t bits = sizeof(type) * CHAR_BIT; \
46 static constexpr int digits = std::numeric_limits<type>::digits; \
47 static constexpr std::string_view name = NAME; \
53#define STRATAX_DEFINE_FLOAT_DTYPE_TRAITS(TYPE, RANK, NAME) \
55 struct DTypeTraitsImpl<TYPE> \
58 static constexpr DTypeKind kind = DTypeKind::Floating; \
59 static constexpr std::size_t bits = sizeof(type) * CHAR_BIT; \
60 static constexpr int digits = std::numeric_limits<type>::digits; \
61 static constexpr std::size_t rank = RANK; \
62 static constexpr std::string_view name = NAME; \
71#define STRATAX_DEFINE_COMPLEX_DTYPE_TRAITS(TYPE, COMPONENT, RANK, NAME) \
73 struct DTypeTraitsImpl<TYPE> \
76 using component_type = COMPONENT; \
77 static constexpr DTypeKind kind = DTypeKind::Complex; \
78 static constexpr std::size_t bits = sizeof(type) * CHAR_BIT; \
79 static constexpr int digits = std::numeric_limits<component_type>::digits; \
80 static constexpr std::size_t rank = RANK; \
81 static constexpr std::string_view name = NAME; \
84STRATAX_DEFINE_DTYPE_TRAITS(dtype::bool_, Bool,
"bool");
86STRATAX_DEFINE_DTYPE_TRAITS(dtype::int8, SignedInteger,
"int8");
87STRATAX_DEFINE_DTYPE_TRAITS(dtype::int16, SignedInteger,
"int16");
88STRATAX_DEFINE_DTYPE_TRAITS(dtype::int32, SignedInteger,
"int32");
89STRATAX_DEFINE_DTYPE_TRAITS(dtype::int64, SignedInteger,
"int64");
91STRATAX_DEFINE_DTYPE_TRAITS(dtype::uint8, UnsignedInteger,
"uint8");
92STRATAX_DEFINE_DTYPE_TRAITS(dtype::uint16, UnsignedInteger,
"uint16");
93STRATAX_DEFINE_DTYPE_TRAITS(dtype::uint32, UnsignedInteger,
"uint32");
94STRATAX_DEFINE_DTYPE_TRAITS(dtype::uint64, UnsignedInteger,
"uint64");
96STRATAX_DEFINE_FLOAT_DTYPE_TRAITS(dtype::float32, 0,
"float32");
97STRATAX_DEFINE_FLOAT_DTYPE_TRAITS(dtype::float64, 1,
"float64");
98STRATAX_DEFINE_FLOAT_DTYPE_TRAITS(dtype::longdouble, 2,
"longdouble");
100STRATAX_DEFINE_COMPLEX_DTYPE_TRAITS(dtype::complex64, dtype::float32, 0,
"complex64");
101STRATAX_DEFINE_COMPLEX_DTYPE_TRAITS(dtype::complex128, dtype::float64, 1,
"complex128");
102STRATAX_DEFINE_COMPLEX_DTYPE_TRAITS(dtype::clongdouble, dtype::longdouble, 2,
"clongdouble");
104#undef STRATAX_DEFINE_DTYPE_TRAITS
105#undef STRATAX_DEFINE_FLOAT_DTYPE_TRAITS
106#undef STRATAX_DEFINE_COMPLEX_DTYPE_TRAITS
128#define STRATAX_DEFINE_COMPLEX_COMPONENT(COMPLEX, REAL) \
130 struct ComplexComponent<COMPLEX> \
135STRATAX_DEFINE_COMPLEX_COMPONENT(dtype::complex64, dtype::float32);
136STRATAX_DEFINE_COMPLEX_COMPONENT(dtype::complex128, dtype::float64);
137STRATAX_DEFINE_COMPLEX_COMPONENT(dtype::clongdouble, dtype::longdouble);
139#undef STRATAX_DEFINE_COMPLEX_COMPONENT
145using complex_component_t =
154#define STRATAX_DEFINE_COMPLEX_FROM_REAL(REAL, COMPLEX) \
156 struct ComplexFromReal<REAL> \
158 using type = COMPLEX; \
161STRATAX_DEFINE_COMPLEX_FROM_REAL(dtype::float32, dtype::complex64);
162STRATAX_DEFINE_COMPLEX_FROM_REAL(dtype::float64, dtype::complex128);
163STRATAX_DEFINE_COMPLEX_FROM_REAL(dtype::longdouble, dtype::clongdouble);
165#undef STRATAX_DEFINE_COMPLEX_FROM_REAL
171using complex_from_real_t =
Maps a complex dtype to its underlying real component dtype.
Maps a real floating-point dtype to its corresponding complex dtype.
Provides compile-time metadata for a supported Stratax dtype.
Implementation registry for supported Stratax dtypes.