Alexandria
2.14.1
Please provide a description of the project.
|
#include <NdArray.h>
Public Types | |
typedef Container< T >::iterator | iterator |
typedef Container< T >::const_iterator | const_iterator |
typedef NdArray< T, Container > | self_type |
Public Member Functions | |
virtual | ~NdArray ()=default |
NdArray (const std::vector< size_t > &shape) | |
NdArray (const std::vector< size_t > &shape, const Container< T > &data) | |
NdArray (const std::vector< size_t > &shape, Container< T > &&data) | |
NdArray (const std::initializer_list< size_t > &shape) | |
NdArray (const self_type &)=default | |
NdArray (self_type &&)=default | |
NdArray & | operator= (const NdArray &)=default |
const std::vector< size_t > | shape () const |
T & | at (const std::vector< size_t > &coords) |
const T & | at (const std::vector< size_t > &coords) const |
template<typename ... D> | |
T & | at (size_t i, D... rest) |
template<typename ... D> | |
const T & | at (size_t i, D... rest) const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
const Container< T > & | data () const |
size_t | size () const |
bool | operator== (const self_type &b) const |
bool | operator!= (const self_type &b) const |
Private Member Functions | |
size_t | getOffset (const std::vector< size_t > &coords) const |
template<typename ... D> | |
T & | at_helper (std::vector< size_t > &acc, size_t i, D... rest) |
T & | at_helper (std::vector< size_t > &acc) |
template<typename ... D> | |
const T & | at_helper (std::vector< size_t > &acc, size_t i, D... rest) const |
const T & | at_helper (std::vector< size_t > &acc) const |
Private Attributes | |
std::vector< size_t > | m_shape |
std::vector< size_t > | m_stride_size |
Container< T > | m_container |
Stores a multidimensional array in a contiguous piece of memory in row-major order
T | Data type |
Container | Which container to use, by default std::vector |
typedef Container<T>::const_iterator Euclid::NdArray::NdArray< T, Container >::const_iterator |
typedef Container<T>::iterator Euclid::NdArray::NdArray< T, Container >::iterator |
typedef NdArray<T, Container> Euclid::NdArray::NdArray< T, Container >::self_type |
|
virtualdefault |
Destructor.
|
inline |
Constructs a default-initialized matrix with the given shape.
shape | The shape of the matrix. The number of elements in shape corresponds to the number of dimensions, the values to each dimension size. |
Definition at line 62 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::shape().
|
inline |
Constructs a matrix and initialize it with the given data.
shape | The shape of the matrix. The number of elements in shape corresponds to the number of dimensions, the values to each dimension size. |
data | The initial data. It must match exactly the matrix size (shape[0]*shape[1]...*shape[n]). |
std::invalid_argument | If the data size does not corresponds to the matrix size. |
Definition at line 83 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::shape().
|
inline |
Constructs a matrix and initialize it with the given data.
shape | The shape of the matrix. The number of elements in shape corresponds to the number of dimensions, the values to each dimension size. |
data | The initial data. It must match exactly the matrix size (shape[0]*shape[1]...*shape[n]). The NdArray will move the data into its internal storage! This avoids a copy, but remember to not use data after this call. |
std::invalid_argument | If the data size does not corresponds to the matrix size. |
Definition at line 110 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::shape().
|
inline |
Constructs a default-initialized matrix with the given shape (as an initializer list).
shape | The shape of the matrix. The number of elements in shape corresponds to the number of dimensions, the values to each dimension size. |
Definition at line 131 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::shape().
|
default |
Copy constructor
|
default |
Move constructor
|
inline |
Gets a reference to the value stored at the given coordinates.
coords | Elements coordinates. |
std::out_of_range | If the number of coordinates is invalid, or any of them is out of bounds. |
Definition at line 164 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::getOffset(), and Euclid::NdArray::NdArray< T, Container >::m_container.
Referenced by Euclid::NdArray::NdArray< T, Container >::at_helper().
|
inline |
Gets a constant reference to the value stored at the given coordinates
coords | Elements coordinates. |
std::out_of_range | If the number of coordinates is invalid, or any of them is out of bounds. |
Definition at line 176 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::getOffset(), and Euclid::NdArray::NdArray< T, Container >::m_container.
|
inline |
Gets a reference to the value stored at the given coordinates.
coords | Elements coordinates. |
std::out_of_range | If the number of coordinates is invalid, or any of them is out of bounds. |
at(x, y, z)
instead of at(std::vector<size_t>{x, y, z})
). Definition at line 192 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::at_helper().
|
inline |
Gets a constant reference to the value stored at the given coordinates.
coords | Elements coordinates. |
std::out_of_range | If the number of coordinates is invalid, or any of them is out of bounds. |
at(x, y, z)
instead of at(std::vector<size_t>{x, y, z})
). Definition at line 208 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::at_helper().
|
inlineprivate |
Helper to expand at with a variable number of arguments
Definition at line 307 of file NdArray.h.
References std::vector< T >::push_back().
Referenced by Euclid::NdArray::NdArray< T, Container >::at(), and Euclid::NdArray::NdArray< T, Container >::at_helper().
|
inlineprivate |
Helper to expand at with a variable number of arguments (base case)
Definition at line 315 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::at().
|
inlineprivate |
Helper to expand constant at with a variable number of arguments
Definition at line 323 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::at_helper(), and std::vector< T >::push_back().
|
inlineprivate |
Helper to expand constant at with a variable number of arguments (base case)
Definition at line 331 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::at().
|
inline |
Definition at line 217 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inline |
Definition at line 233 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inline |
Definition at line 248 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
Referenced by Euclid::NdArray::NdArray< T, Container >::operator!=(), and Euclid::NdArray::NdArray< T, Container >::operator==().
|
inline |
Definition at line 225 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inline |
Definition at line 241 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inlineprivate |
Gets the total offset for the given coordinates.
std::out_of_range | If the number of coordinates is invalid, or any of them is out of bounds. |
Definition at line 282 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container, Euclid::NdArray::NdArray< T, Container >::m_shape, Euclid::NdArray::NdArray< T, Container >::m_stride_size, std::vector< T >::size(), and std::to_string().
Referenced by Euclid::NdArray::NdArray< T, Container >::at().
|
inline |
Two NdArrays are not equal if their shapes or their content are not equal
Definition at line 269 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::data(), and Euclid::NdArray::NdArray< T, Container >::shape().
|
default |
Assignment
|
inline |
Two NdArrays are equal if their shapes and their content are equal
Definition at line 262 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::data(), and Euclid::NdArray::NdArray< T, Container >::shape().
|
inline |
Gets the shape of the matrix.
Definition at line 153 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_shape.
Referenced by Euclid::NdArray::NdArray< T, Container >::NdArray(), Euclid::NdArray::NdArray< T, Container >::operator!=(), and Euclid::NdArray::NdArray< T, Container >::operator==().
|
inline |
Size of the underlying container
Definition at line 255 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
private |
Definition at line 275 of file NdArray.h.
Referenced by Euclid::NdArray::NdArray< T, Container >::at(), Euclid::NdArray::NdArray< T, Container >::begin(), Euclid::NdArray::NdArray< T, Container >::data(), Euclid::NdArray::NdArray< T, Container >::end(), Euclid::NdArray::NdArray< T, Container >::getOffset(), and Euclid::NdArray::NdArray< T, Container >::size().
|
private |
Definition at line 274 of file NdArray.h.
Referenced by Euclid::NdArray::NdArray< T, Container >::getOffset(), and Euclid::NdArray::NdArray< T, Container >::shape().
|
private |
Definition at line 274 of file NdArray.h.
Referenced by Euclid::NdArray::NdArray< T, Container >::getOffset().