|
MTCT
Design Automation and Optimization for ETCS Railway Networks
|
A dynamically-shaped N-dimensional array stored in row-major order. More...
#include <MultiArray.hpp>
Public Member Functions | |
| template<typename... Args> | |
| MultiArray (Args... args) | |
| Constructs a MultiArray with the given dimension extents. | |
| template<typename... Args> | |
| T & | operator() (Args... args) |
| Checked multi-dimensional element access (non-const). | |
| template<typename... Args> | |
| T & | at (Args... args) |
| Bounds-checked multi-dimensional element access (non-const). | |
| template<typename... Args> | |
| const T & | at (Args... args) const |
| Bounds-checked multi-dimensional element access (const). | |
| const FixedSizeVector< size_t > & | get_shape () const |
| Provides the shape of the array. | |
| size_t | size () const |
| Computes the total number of elements in the array. | |
| size_t | dimensions () const |
| Gets the number of dimensions. | |
| const T * | begin () const |
| Iterates over all elements in row-major order. | |
| const T * | end () const |
| The end of the iteration, see begin(). | |
A dynamically-shaped N-dimensional array stored in row-major order.
The shape (number of dimensions and the extent of each dimension) is fixed at construction time. Element storage is a flat FixedSizeVector<T> whose length equals the product of all dimension extents. Multi-dimensional indices are linearised using a row-major (last-index-fastest) scheme.
A zero-dimensional MultiArray behaves like a scalar: it contains exactly one element that is accessed via operator()() or at().
| T | Element type. Must be default-constructible. |
|
inlineexplicit |
Constructs a MultiArray with the given dimension extents.
Pass one extent per dimension (e.g. MultiArray<int>(3, 4) creates a 3×4 matrix). Passing no arguments creates a zero-dimensional scalar array containing exactly one element.
| Args | Integral types convertible to size_t. |
| args | Extents of each dimension, in order. |
| std::invalid_argument | If any argument is a negative signed value. |
|
inlinenodiscard |
Bounds-checked multi-dimensional element access (non-const).
| Args | Integral types convertible to size_t. |
| args | One index per dimension. |
| std::invalid_argument | If the number of arguments differs from dimensions(). |
| std::out_of_range | If any index exceeds its dimension's extent. |
|
inlinenodiscard |
Bounds-checked multi-dimensional element access (const).
| Args | Integral types convertible to size_t. |
| args | One index per dimension. |
| std::invalid_argument | If the number of arguments differs from dimensions(). |
| std::out_of_range | If any index exceeds its dimension's extent. |
|
inlinenodiscard |
Iterates over all elements in row-major order.
|
inlinenodiscard |
Gets the number of dimensions.
|
inlinenodiscard |
The end of the iteration, see begin().
|
inlinenodiscard |
Provides the shape of the array.
|
inline |
Checked multi-dimensional element access (non-const).
The number of arguments must equal dimensions() and each index must be within bounds; these conditions are enforced via flat_index/check_args. The operator syntax mirrors array access, but this is not unchecked access.
| Args | Integral types convertible to size_t. |
| args | One index per dimension. |
| std::invalid_argument | If the number of arguments differs from dimensions(). |
| std::out_of_range | If any index exceeds its dimension's extent. |
|
inlinenodiscard |
Computes the total number of elements in the array.