![]() |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Helper class that carries meta-information about container's size and dimensions.
#include <MArrayDimensions.h>
Public Member Functions | |
| MArrayDimensions ()=default | |
| Default constructor. More... | |
| MArrayDimensions (std::initializer_list< mint > dimensions) | |
| Constructs MArrayDimensions from a list of dimensions. More... | |
| template<typename T , typename = typename std::enable_if_t<std::is_integral_v<T>>> | |
| MArrayDimensions (const T *dimensions, mint rank) | |
| Constructs MArrayDimensions from a C-style list (raw pointer + length) More... | |
| template<typename T , typename = typename std::enable_if_t<std::is_integral_v<T>>> | |
| MArrayDimensions (const std::vector< T > &dimensions) | |
| Constructs MArrayDimensions from a vector of dimensions. More... | |
| template<typename InputIter , typename = enable_if_input_iterator<InputIter>> | |
| MArrayDimensions (InputIter dimsBegin, InputIter dimsEnd) | |
| Create new dimensions from a range. More... | |
| mint | rank () const noexcept |
| Get container rank. More... | |
| const mint * | data () const noexcept |
| Get raw pointer to container dimensions. More... | |
| const std::vector< mint > & | get () const noexcept |
| Get container dimensions in the form of const& to std::vector. More... | |
| mint | get (mint dim) const |
| Get single dimension. More... | |
| mint | getIndex (const std::vector< mint > &indices) const |
| Convert coordinates of an element in a multidimensional MArray to the corresponding index in a flat list of elements. More... | |
| mint | getIndexChecked (const std::vector< mint > &indices) const |
| Check if given coordinates are valid for this container. More... | |
| mint | getIndexChecked (mint index) const |
| Check if given index is valid i.e. More... | |
| mint | flatCount () const noexcept |
| Get total number of elements. More... | |
|
default |
Default constructor.
| LLU::MArrayDimensions::MArrayDimensions | ( | std::initializer_list< mint > | dimensions | ) |
Constructs MArrayDimensions from a list of dimensions.
| [in] | dimensions | - list of MArray dimensions |
| ErrorName::DimensionsError | - if dims are invalid |
| ErrorName::FunctionError | - if any of Wolfram*Library structures was not initialized |
| LLU::MArrayDimensions::MArrayDimensions | ( | const T * | dimensions, |
| mint | rank | ||
| ) |
Constructs MArrayDimensions from a C-style list (raw pointer + length)
| [in] | dimensions | - pointer to the memory where consecutive dimensions are stored |
| [in] | rank | - length of the dims array |
| ErrorName::DimensionsError | - if dims are invalid |
| ErrorName::FunctionError | - if any of Wolfram*Library structures was not initialized |
|
explicit |
Constructs MArrayDimensions from a vector of dimensions.
| [in] | dimensions | - vector with MArray dimensions |
| ErrorName::DimensionsError | - if dims are invalid |
| ErrorName::FunctionError | - if any of Wolfram*Library structures was not initialized |
| LLU::MArrayDimensions::MArrayDimensions | ( | InputIter | dimsBegin, |
| InputIter | dimsEnd | ||
| ) |
Create new dimensions from a range.
| InputIter | - any type that is an input iterator |
| dimsBegin | - range begin |
| dimsEnd | - range end |
|
inlinenoexcept |
Get raw pointer to container dimensions.
|
inlinenoexcept |
Get total number of elements.
|
inlinenoexcept |
Get container dimensions in the form of const& to std::vector.
|
inline |
Get single dimension.
| [in] | dim | - index of desired dimension |
| indexError() | - if dim is out-of-bounds |
| mint LLU::MArrayDimensions::getIndex | ( | const std::vector< mint > & | indices | ) | const |
Convert coordinates of an element in a multidimensional MArray to the corresponding index in a flat list of elements.
| [in] | indices | - vector with coordinates of desired data element |
| mint LLU::MArrayDimensions::getIndexChecked | ( | const std::vector< mint > & | indices | ) | const |
Check if given coordinates are valid for this container.
| [in] | indices | - vector with coordinates of desired data element |
| indexError() | - if indices are out-of-bounds |
| mint LLU::MArrayDimensions::getIndexChecked | ( | mint | index | ) | const |
Check if given index is valid i.e.
it does not exceed container bounds
| index | - index of the desired element |
|
inlinenoexcept |
Get container rank.