# Common type definitions#

This section describes common types used in oneDAL.

## Programming interface#

All types and functions in this section shall be declared in the oneapi::dal namespace and be available via inclusion of the oneapi/dal/common.hpp header file.

### Scalar types#

oneDAL relies on the use of integral types defined in <cstdint>. This file shall be included in oneapi/dal/common.hpp and all oneDAL types shall use these data types.

The interfaces of the library shall use std::int64_t data type to represent dimensionality (for example, the number of rows and columns in the table).

It is recommended to use standard C++ types for applications as well.

### Enum classes#

Which base type to use when defining enum or enum class representing a oneDAL concept is up to the implementer unless specification requires a specific base type.

### Data type#

The implementation of data type concept. It shall enumerate all the data types supported by oneDAL to perform computations. The data_type class shall contain all the base scalar types and can also extend them. Base scalar types include the types whose names follow the pattern std::int_XX_t or std::uint_XX_t, where XX is 8, 16, 32, or 64.

enum class data_type {
int8,
int16,
int32,
int64,
uint8,
uint16,
uint32,
uint64,
float32,
float64,
bfloat16
};

enum class data_type#
data_type::int8

8-bit signed integer value type.

data_type::int16

16-bit signed integer value type.

data_type::int32

32-bit signed integer value type.

data_type::int64

64-bit signed integer value type.

data_type::uint8

8-bit unsigned integer value type.

data_type::uint16

16-bit unsigned integer value type.

data_type::uint32

32-bit unsigned integer value type.

data_type::uint64

64-bit unsigned integer value type.

data_type::float32

32-bit floating-point value type.

data_type::float64

64-bit floating-point value type.

data_type::bfloat16

bi-float value type.

### Range#

A range [start_index, end_index) in an array or any other container that supports value indexing.

struct range {
public:
range(std::int64_t start, std::int64_t end);

std::int64_t get_element_count(std::int64_t max_end_index) const noexcept;

std::int64_t start_idx;

std::int64_t end_idx;
};

struct range#

Constructors

range(std::int64_t start, std::int64_t end)#

Constructs a range of elements from the given start and end indices.

Parameters
• start – The first index in the range. The value shall be greater than or equal to 0.

• end – The relative end index in the range. Indicates the next index after the last one in the range. If positive, shall be greater than $$start$$. If negative, indicates the offset of the last element from the end of the range. For example, start = 1 and end = -2 specify the range of elements [1, 2, 3] in the set [0, 1, 2, 3, 4].

Public Methods

std::int64_t get_element_count(std::int64_t max_end_index) const noexcept#

The number of elements in the range. The max_end_index value specifies the last maximal index in the sequence.