Alexandria
2.16
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) | |
template<typename Iterator > | |
NdArray (const std::vector< size_t > &shape, Iterator begin, Iterator end) | |
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 |
self_type & | reshape (const std::vector< size_t > new_shape) |
template<typename ... D> | |
self_type & | reshape (size_t i, D... rest) |
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 | get_offset (const std::vector< size_t > &coords) const |
void | update_strides () |
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 |
template<typename ... D> | |
self_type & | reshape_helper (std::vector< size_t > &acc, size_t i, D... rest) |
self_type & | reshape_helper (std::vector< size_t > &acc) |
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.
|
inlineexplicit |
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 77 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 97 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::shape().
|
inline |
Constructs a matrix and initialize it with from the given iterators
shape | The shape of the matrix. The number of elements in shape corresponds to the number of dimensions, the values to each dimension size. |
begin | The beginning of the data |
end | The end of the data |
std::invalid_argument | If the data size does not corresponds to the matrix size. |
Definition at line 118 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 132 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 201 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::get_offset(), 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 213 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::get_offset(), 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 229 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 245 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 357 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 365 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 373 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 381 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::at().
|
inline |
Definition at line 254 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inline |
Definition at line 270 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inline |
Definition at line 285 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 262 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inline |
Definition at line 278 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 319 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 306 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 299 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::data(), and Euclid::NdArray::NdArray< T, Container >::shape().
|
inline |
Reshape the NdArray.
new_shape | A vector with as many elements as number of dimensions, containing the size of each one. |
std::range_error | If the new shape does not match the number of elements already contained within the NdArray. |
Definition at line 168 of file NdArray.h.
References std::accumulate(), std::vector< T >::begin(), std::vector< T >::end(), Euclid::NdArray::NdArray< T, Container >::m_container, Euclid::NdArray::NdArray< T, Container >::m_shape, and Euclid::NdArray::NdArray< T, Container >::update_strides().
Referenced by Euclid::NdArray::NdArray< T, Container >::reshape_helper().
|
inline |
Reshape the NdArray.
new_shape | A vector with as many elements as number of dimensions, containing the size of each one. |
std::range_error | If the new shape does not match the number of elements already contained within the NdArray. |
Definition at line 189 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::reshape_helper().
|
inlineprivate |
Definition at line 386 of file NdArray.h.
References std::vector< T >::push_back().
Referenced by Euclid::NdArray::NdArray< T, Container >::reshape().
|
inlineprivate |
Definition at line 391 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::reshape().
|
inline |
Gets the shape of the matrix.
Definition at line 154 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 292 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_container.
|
inlineprivate |
Compute the stride size for each dimension
Definition at line 343 of file NdArray.h.
References Euclid::NdArray::NdArray< T, Container >::m_shape, Euclid::NdArray::NdArray< T, Container >::m_stride_size, std::vector< T >::resize(), and std::vector< T >::size().
Referenced by Euclid::NdArray::NdArray< T, Container >::reshape().
|
private |
Definition at line 312 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 >::get_offset(), Euclid::NdArray::NdArray< T, Container >::reshape(), and Euclid::NdArray::NdArray< T, Container >::size().
|
private |
|
private |
Definition at line 311 of file NdArray.h.
Referenced by Euclid::NdArray::NdArray< T, Container >::get_offset(), and Euclid::NdArray::NdArray< T, Container >::update_strides().