8 #ifndef META_OCEAN_BASE_DATA_TYPE_H
9 #define META_OCEAN_BASE_DATA_TYPE_H
25 template <
typename T,
unsigned int tElements>
51 static_assert(
sizeof(
Type) ==
sizeof(T) * tElements,
"Invalid data type!");
123 template <
typename T>
167 template <
typename T>
216 template <
typename T>
225 typedef unsigned long long Type;
246 template <
typename T>
286 template <
typename T>
331 template <
typename T>
367 template <
typename T>
387 template <
typename T>
443 template <
typename T>
444 static inline const char*
name();
462 template <
size_t tBytes>
465 static_assert(tBytes == 1 || tBytes == 2 || tBytes == 4 || tBytes == 8,
"Invalid data type!");
498 template <
typename T>
501 static_assert(
sizeof(T) == 1 ||
sizeof(T) == 2 ||
sizeof(T) == 4 ||
sizeof(T) == 8,
"Invalid data type!");
516 template <
bool tOrderedKeys>
524 template <
typename TKey,
typename TElement>
525 using TMap = std::map<TKey, TElement>;
539 template <
typename TKey,
typename TElement>
540 using TMap = std::unordered_map<TKey, TElement>;
562 inline Float16(
const uint16_t sign,
const uint16_t fraction,
const uint16_t exponent);
568 explicit inline Float16(
const uint16_t binary);
574 inline uint16_t binary()
const;
580 explicit operator float()
const;
593 inline bool operator==(
const Float16& second)
const;
600 inline bool operator!=(
const Float16& second)
const;
606 static inline Float16 infinity();
616 uint16_t binary_ = 0u;
635 template <
typename T,
unsigned int tElements>
638 for (
unsigned int n = 0u; n < tElements; ++n)
649 template <
typename T,
unsigned int tElements>
652 return !(*
this == type);
764 typedef unsigned long long Type;
1107 static const bool isSigned =
false;
1112 static const bool hasSigned =
false;
1140 static const bool isSigned =
false;
1145 static const bool hasSigned =
true;
1164 static const bool isSigned =
false;
1169 static const bool hasSigned =
true;
1188 static const bool isSigned =
false;
1193 static const bool hasSigned =
true;
1221 static const bool isUnsigned =
false;
1226 static const bool hasUnsigned =
true;
1245 static const bool isUnsigned =
false;
1250 static const bool hasUnsigned =
true;
1269 static const bool isUnsigned =
false;
1274 static const bool hasUnsigned =
true;
1293 static const bool isUnsigned =
false;
1298 static const bool hasUnsigned =
true;
1317 static const bool isUnsigned =
false;
1322 static const bool hasUnsigned =
true;
1341 static const bool isUnsigned =
false;
1346 static const bool hasUnsigned =
false;
1365 static const bool isUnsigned =
false;
1370 static const bool hasUnsigned =
false;
1386 inline const char* TypeNamer::name<bool>()
1388 static const char* value =
"bool";
1393 inline const char* TypeNamer::name<char>()
1395 static const char* value =
"char";
1400 inline const char* TypeNamer::name<signed char>()
1402 static const char* value =
"signed char";
1407 inline const char* TypeNamer::name<unsigned char>()
1409 static const char* value =
"unsigned char";
1414 inline const char* TypeNamer::name<short>()
1416 static const char* value =
"short";
1421 inline const char* TypeNamer::name<unsigned short>()
1423 static const char* value =
"unsigned short";
1428 inline const char* TypeNamer::name<int>()
1430 static const char* value =
"int";
1435 inline const char* TypeNamer::name<unsigned int>()
1437 static const char* value =
"unsigned int";
1442 inline const char* TypeNamer::name<long>()
1444 static const char* value =
"long";
1449 inline const char* TypeNamer::name<unsigned long>()
1451 static const char* value =
"unsigned long";
1456 inline const char* TypeNamer::name<long long>()
1458 static const char* value =
"long long";
1463 inline const char* TypeNamer::name<unsigned long long>()
1465 static const char* value =
"unsigned long long";
1470 inline const char* TypeNamer::name<float>()
1472 static const char* value =
"float";
1477 inline const char* TypeNamer::name<double>()
1479 static const char* value =
"double";
1541 ocean_assert(sign <= 1u);
1542 ocean_assert(fraction <= 1023u);
1543 ocean_assert(exponent <= 31u);
1545 data_.ieee_.fraction_ = fraction;
1546 data_.ieee_.exponent_ = exponent;
1547 data_.ieee_.sign_ = sign;
1552 data_.binary_ = binary;
1557 return data_.binary_;
1562 return Float16((~data_.ieee_.sign_) & 0x1u, data_.ieee_.fraction_, data_.ieee_.exponent_);
1572 return !(*
this == second);
1577 constexpr uint16_t maxExponent = 31u;
1579 return Float16(0u, maxExponent, 0u);
unsigned int Type
Definition of the absolute difference value type.
Definition: DataType.h:890
double Type
Definition of the absolute difference value type.
Definition: DataType.h:946
double Type
Definition of the absolute difference value type.
Definition: DataType.h:932
unsigned int Type
Definition of the absolute difference value type.
Definition: DataType.h:904
unsigned int Type
Definition of the absolute difference value type.
Definition: DataType.h:918
This class is a helper class allowing to define the resulting data type for an absolute difference op...
Definition: DataType.h:218
unsigned long long Type
Definition of the data type for the absolute difference value.
Definition: DataType.h:225
Template class allowing to define an array of data types.
Definition: DataType.h:27
int Type
Definition of the signed distance type.
Definition: DataType.h:778
int Type
Definition of the signed distance type.
Definition: DataType.h:834
int Type
Definition of the signed distance type.
Definition: DataType.h:792
int Type
Definition of the signed distance type.
Definition: DataType.h:806
int Type
Definition of the signed distance type.
Definition: DataType.h:820
long Type
Definition of the signed distance type.
Definition: DataType.h:862
long long Type
Definition of the signed distance type.
Definition: DataType.h:876
int Type
Definition of the signed distance type.
Definition: DataType.h:848
This class is a helper class allowing to define the signed difference data type of a given type.
Definition: DataType.h:169
T Type
Definition of the data type for the signed difference value.
Definition: DataType.h:176
Definition of a 16-bit float type.
Definition: DataType.h:548
bool operator==(const Float16 &second) const
Returns whether two 16-bit float values are identical.
Definition: DataType.h:1565
union Ocean::Float16::@0 data_
Union allowing to access the binary representation or the IEEE representation.
uint16_t binary() const
Returns the binary representation of this 16-bit float value.
Definition: DataType.h:1555
uint16_t exponent_
The exponent composed of 5 bits.
Definition: DataType.h:627
uint16_t sign_
The sign composed of 1 bit.
Definition: DataType.h:630
Float16()=default
Default constructor.
bool operator!=(const Float16 &second) const
Returns whether two 16-bit float values are not identical.
Definition: DataType.h:1570
static Float16 infinity()
Returns +infinity.
Definition: DataType.h:1575
uint16_t binary_
The binary representation.
Definition: DataType.h:616
uint16_t fraction_
The mantissa composed of 10 bits.
Definition: DataType.h:624
Float16 operator-() const
Negates the 16-bit float value.
Definition: DataType.h:1560
This class implements a helper class allowing to define the identity data type of a given type.
Definition: DataType.h:86
T Type
The data type of 'T'.
Definition: DataType.h:90
std::unordered_map< TKey, TElement > TMap
Definition of an unordered map.
Definition: DataType.h:540
Helper class allowing to define an ordered or unordered map based on the template parameter 'tOrdered...
Definition: DataType.h:518
std::map< TKey, TElement > TMap
Definition of an ordered map.
Definition: DataType.h:525
double Type
Definition of the data type for the next larger data type.
Definition: DataType.h:1083
float TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:1088
long long TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:1050
long long Type
Definition of the data type for the next larger data type.
Definition: DataType.h:1045
int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:1012
int Type
Definition of the data type for the next larger data type.
Definition: DataType.h:1007
int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:974
short Type
Definition of the data type for the next larger data type.
Definition: DataType.h:969
unsigned int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:993
unsigned short Type
Definition of the data type for the next larger data type.
Definition: DataType.h:988
unsigned long long Type
Definition of the data type for the next larger data type.
Definition: DataType.h:1064
unsigned long long TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:1069
unsigned int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:1031
unsigned int Type
Definition of the data type for the next larger data type.
Definition: DataType.h:1026
This class is a helper class allowing to determine the next larger data type for a given data type.
Definition: DataType.h:248
T Type
Definition of the data type for the next larger data type.
Definition: DataType.h:255
T TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:261
bool Type
Definition of the data type which is 'bool' in case of 'T' is 'void'.
Definition: DataType.h:418
static constexpr bool defaultValue()
Returns a default value for 'T'.
Definition: DataType.h:424
This struct implements a helper struct allowing to use a data type instead of void.
Definition: DataType.h:389
T Type
Definition of the data type which is 'bool' in case of 'T' is 'void'.
Definition: DataType.h:395
static constexpr T defaultValue()
Returns a default value for 'T'.
Definition: DataType.h:401
bool Type
Definition of the signed data type, if existing.
Definition: DataType.h:1102
int Type
Definition of the signed data type, if existing.
Definition: DataType.h:1159
long long Type
Definition of the signed data type, if existing.
Definition: DataType.h:1183
short Type
Definition of the signed data type, if existing.
Definition: DataType.h:1135
This class is a helper class allowing to determine the signed data type for a given data type if exis...
Definition: DataType.h:288
static const bool hasSigned
True, if the data has a corresponding signed data type (or itself is signed).
Definition: DataType.h:304
static const bool isSigned
True, if the data type T is an signed data type; False, otherwise.
Definition: DataType.h:299
T Type
Definition of the signed data type, if existing.
Definition: DataType.h:294
unsigned int Type
Definition of the square distance type.
Definition: DataType.h:680
unsigned int Type
Definition of the square distance type.
Definition: DataType.h:666
unsigned long Type
Definition of the square distance type.
Definition: DataType.h:750
unsigned long long Type
Definition of the square distance type.
Definition: DataType.h:764
unsigned int Type
Definition of the square distance type.
Definition: DataType.h:722
unsigned int Type
Definition of the square distance type.
Definition: DataType.h:694
unsigned int Type
Definition of the square distance type.
Definition: DataType.h:708
unsigned int Type
Definition of the square distance type.
Definition: DataType.h:736
This class is a helper class allowing to define the square difference data type of a given type.
Definition: DataType.h:125
T Type
Definition of the data type for the square value.
Definition: DataType.h:132
uint8_t Type
Definition of the mapped data type.
Definition: DataType.h:1494
uint16_t Type
Definition of the mapped data type.
Definition: DataType.h:1508
uint32_t Type
Definition of the mapped data type.
Definition: DataType.h:1522
uint64_t Type
Definition of the mapped data type.
Definition: DataType.h:1536
This class provides a unique data type for any data type specified by the number of bytes.
Definition: DataType.h:464
void Type
Definition of an invalid mapped data type.
Definition: DataType.h:465
This class provides a unique data type for any data type.
Definition: DataType.h:500
TypeMapperBySize< sizeof(T)>::Type Type
Definition of an invalid mapped data type.
Definition: DataType.h:501
This class implements a helper class allowing to determine unique names for most of native C++ data t...
Definition: DataType.h:435
static const char * name()
Returns a user-friendly name for most of native C++ data types.
double Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:1360
float Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:1336
unsigned int Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:1264
unsigned long Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:1288
unsigned long long Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:1312
unsigned short Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:1240
unsigned char Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:1216
This class is a helper class allowing to determine the unsigned data type for a given data type if ex...
Definition: DataType.h:333
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition: DataType.h:349
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition: DataType.h:344
T Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:339
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition: AutomaticDifferentiation.h:484
Default definition of a type with tBytes bytes.
Definition: DataType.h:32
T values_[tElements]
Data values of the type.
Definition: DataType.h:48
bool operator!=(const Type &type) const
Returns whether two objects do not store the same values.
Definition: DataType.h:650
bool operator==(const Type &type) const
Returns whether two objects store the same values.
Definition: DataType.h:636
double Type
The 64 bit floating point data type if T is 'double'.
Definition: DataType.h:1382
This struct is a helper struct providing a floating point data type best matching for a given data ty...
Definition: DataType.h:369
float Type
The 32 bit floating point data type for any data type T but 'double'.
Definition: DataType.h:373