| IOLink 1.11.0

Loading...
Searching...
No Matches
Public Member Functions | List of all members
iolink::Indexer Class Referencefinal

This class is used to index a classic array into a multi dimensional array. More...

`#include <iolink/Indexer.h>`

## Public Member Functions
| Indexer (const VectorXu64 &shape, const VectorXu64 &stride, const VectorXu64 &layout)
| Create an indexer by giving all its informations.
| Indexer (const VectorXu64 &shape, const VectorXu64 &stride, MemoryLayout standardLayout)
| Create an indexer by giving all its informations.
| Indexer (const VectorXu64 &shape, const VectorXu64 &layout)
| Initialize the indexer using a custom memory layout.
| Indexer (const VectorXu64 &shape, MemoryLayout standardLayout)
| Auto compute the Indexer's strides from shape and standard layout.
| Indexer (const VectorXu64 &shape)
| Simpliest way to initialize an indexer from a shape.
| Indexer (const VectorXu64 &shape, DataType dtype)
| Constructor with shape and datatype, using default layout and stride.
| Indexer (const VectorXu64 &shape, DataType dtype, MemoryLayout standardLayout)
| Constructor with shape, datatype and standard layout, using default stride.
| Indexer (const VectorXu64 &shape, DataType dtype, const VectorXu64 &byteStride)
| Constructor with shape, datatype and byte stride, using default layout.
| Indexer (const VectorXu64 &shape, DataType dtype, const VectorXu64 &byteStride, const VectorXu64 &layout)
| Constructor with shape, datatype, byte stride and layout.
| Indexer (const Indexer &other)
Indexer & | operator= (const Indexer &other)
| Indexer (Indexer &&other) noexcept
Indexer & | operator= (Indexer &&other) noexcept
bool | operator== (const Indexer &other) const
bool | operator!= (const Indexer &other) const
size_t | dimensionCount () const
| The number of dimensions managed by this indexer.
const VectorXu64 & | shape () const
| Return the shape.
DataType | dtype () const
const VectorXu64 & | stride () const
| Return the stride.
const VectorXu64 & | byteStride () const
const VectorXu64 & | layout () const
| Return the layout dimension order.
size_t | shape (size_t index) const
| Return the current size for given dimension.
size_t | stride (size_t index) const
| Return the current stride for given dimension.
size_t | byteStride (size_t index) const
size_t | layout (size_t index) const
| Return the dimension index of the nth one in order.
size_t | elementCount () const
| Returns the number of elements managed by this Indexer.
size_t | byteCount () const
| Get the total number of bytes needed to adress this indexer, taking the padding into account.
size_t | offset (const VectorXu64 &index) const
| Return the computed 1D offset corresponding to indexed sample in multi dimensional array.
size_t | byteOffset (const VectorXu64 &index) const
| Computes the offset in bytes to the given index.
bool | isContinuous () const
| Checks if the indexed elements are contiguous.

## Detailed Description

This class is used to index a classic array into a multi dimensional array.

Its main use is to convert a multi-dimensional index into the corresponding offset in the flat array used for storage. An indexer contains all the needed tools and describes how the data is really stored. The three main elements are: the shape, the stride, and the layout.

The shape is simply the size of the indexed array in each dimension, for example an array with two columns and two rows will have a shape of {2, 2}.

The stride contains the offset between each iteration of a dimension, in elements. For example, our {2, 2} array will usually have a stride of {1, 2}, as each column element is adjacent (hence the stride of one), and when iterating element on a line, you must skip one element on the underlying array (hence the stride of 2). The stride dimension are in the same order as the shape, but they do not have to be in ascendent order. Actually, reverse order arrays (C convention) will have inversed strides, for example, {2, 1} in our {2, 2} array case.

The layout describes in wich order each dimension is ordered internally, and can be used to enhance performance. The usual IOLink layout is {0, 1, ..., n - 1, n}. As we use the Fortran convention in IOLink, indexing a C array would use an inverted layout {n, n-1, ..., 1, 0}. This field enables user to easily know how data is organised without analysing the strides directly.

## Constructor & Destructor Documentation

## ◆ Indexer() [1/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | const VectorXu64 & | stride,
|  | const VectorXu64 & | layout
| ) |  |

Create an indexer by giving all its informations.

Here all the arguments are given, and are not checked, so if they are not consistant, they will give an undefined behavior.

Parameters

  shape | The shape of the array to index.
  stride | The stride of each dimension, the offset in elements between each increment in this dimension.
  layout | The internal order of dimensions, {0, 1} is row-major and {1, 0} is col-major for example.

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use a constructor that specify the data type instead.

## ◆ Indexer() [2/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | const VectorXu64 & | stride,
|  | MemoryLayout | standardLayout
| ) |  |

Create an indexer by giving all its informations.

Here all the arguments are given, and are not checked, so if they are not consistant, they will give an undefined behavior.

Parameters

  shape | The shape of the array to index.
  stride | The stride of each dimension, the offset in elements between each increment in this dimension.
  standardLayout | A standard layout for the array.

Exceptions

  Error | When the layout is unsupported

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use a constructor that specify the data type instead.

## ◆ Indexer() [3/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | const VectorXu64 & | layout
| ) |  |

Initialize the indexer using a custom memory layout.

Parameters

  shape | The shape of the indexed array
  layout | The internal order of dimensions, {0, 1} is row-major and {1, 0} is col-major for example.

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use a constructor that specify the data type instead.

## ◆ Indexer() [4/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | MemoryLayout | standardLayout
| ) |  |

Auto compute the Indexer's strides from shape and standard layout.

Parameters

  shape | The narray sizes in each dimension
  standardLayout | A standard layout for the array.

Exceptions

  Error | When the layout is unsupported

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use a constructor that specify the data type instead.

## ◆ Indexer() [5/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape | ) |
| explicit

Simpliest way to initialize an indexer from a shape.

The layout here is Fortran one, and the strides are computed according to it.

Parameters

  shape | The desired shape of the multi dimensional array.

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use a constructor that specify the data type instead.

## ◆ Indexer() [6/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | DataType | dtype
| ) |  |

Constructor with shape and datatype, using default layout and stride.

The default byte stride being computed from the shape and data type. The default layout being the Fortran array layout.

Parameters

  shape | The shape of the indexed array.
  dtype | The data type of the indexed array.

## ◆ Indexer() [7/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | DataType | dtype,
|  | MemoryLayout | standardLayout
| ) |  |

Constructor with shape, datatype and standard layout, using default stride.

The default byte stride being computed from the shape, datatype, and standard layout.

Parameters

  shape | The shape of the indexed array.
  dtype | The data type of the indexed array.
  standardLayout | A standard layout for the array.

## ◆ Indexer() [8/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | DataType | dtype,
|  | const VectorXu64 & | byteStride
| ) |  |

Constructor with shape, datatype and byte stride, using default layout.

The default layout being the Fortran array layout.

Parameters

  shape | The shape of the indexed array.
  dtype | The data type of the indexed array.
  byteStride | The stride in bytes of the indexed array.

## ◆ Indexer() [9/9]

iolink::Indexer::Indexer | ( | const VectorXu64 & | shape,
|  | DataType | dtype,
|  | const VectorXu64 & | byteStride,
|  | const VectorXu64 & | layout
| ) |  |

Constructor with shape, datatype, byte stride and layout.

Parameters

  shape | The shape of the indexed array.
  dtype | The data type of the indexed array.
  byteStride | The stride in bytes of the indexed array.
  layout | The layout of the indexed array.

## Member Function Documentation

## ◆ byteCount()

size_t iolink::Indexer::byteCount | ( |  | ) | const

Get the total number of bytes needed to adress this indexer, taking the padding into account.

Returns
  the number of bytes managed by this Indexer.

## ◆ byteOffset()

size_t iolink::Indexer::byteOffset | ( | const VectorXu64 & | index | ) | const

Computes the offset in bytes to the given index.

Parameters

  index | The index of the element for which the offset must be computed.

Returns
  the offset in bytes to the given index.

Exceptions

  InvalidArgument | If the index is invalid.

## ◆ byteStride() [1/2]

const VectorXu64 & iolink::Indexer::byteStride | ( |  | ) | const

Returns
  the stride in bytes of this Indexer.

## ◆ byteStride() [2/2]

size_t iolink::Indexer::byteStride | ( | size_t | index | ) | const

Returns
  the stride in bytes for the given dimension.

## ◆ dtype()

DataType iolink::Indexer::dtype | ( |  | ) | const

Returns
  the data type of this Indexer.

## ◆ isContinuous()

bool iolink::Indexer::isContinuous | ( |  | ) | const

Checks if the indexed elements are contiguous.

Elements are considered contiguous if they follow each other without any padding.

Returns
  true if the indexed elements are continuous, false otherwise.

## ◆ layout()

size_t iolink::Indexer::layout | ( | size_t | index | ) | const

Return the dimension index of the nth one in order.

Parameters

  index | Index of the order dimension index.

## ◆ offset()

size_t iolink::Indexer::offset | ( | const VectorXu64 & | index | ) | const

Return the computed 1D offset corresponding to indexed sample in multi dimensional array.

Parameters

  index | The element's position for which offset must be computed.

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use the byteOffset method instead.

## ◆ shape()

size_t iolink::Indexer::shape | ( | size_t | index | ) | const

Return the current size for given dimension.

Parameters

  index | Index of the dimension to consider

## ◆ stride() [1/2]

const VectorXu64 & iolink::Indexer::stride | ( |  | ) | const

Return the stride.

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use the byteStride method instead.

## ◆ stride() [2/2]

size_t iolink::Indexer::stride | ( | size_t | index | ) | const

Return the current stride for given dimension.

Parameters

  index | Index of the dimension to consider

Deprecated:
  Deprecated in 1.8, will be dropped in 2.0, you should use the byteStride method instead.

The documentation for this class was generated from the following file:

- iolink/public/include/iolink/Indexer.h