Alexandria
2.18
Please provide a description of the project.
|
#include <NdArray.h>
Classes | |
struct | ContainerInterface |
struct | ContainerWrapper |
class | Iterator |
Public Types | |
typedef NdArray< T > | self_type |
typedef Iterator< true > | const_iterator |
typedef Iterator< false > | iterator |
Public Member Functions | |
virtual | ~NdArray ()=default |
NdArray (const std::vector< size_t > &shape_) | |
template<template< class... > class Container = std::vector> | |
NdArray (const std::vector< size_t > &shape_, const Container< T > &data) | |
template<template< class... > class Container = std::vector> | |
NdArray (const std::vector< size_t > &shape_, Container< T > &&data) | |
template<typename Iterator > | |
NdArray (const std::vector< size_t > &shape_, Iterator begin, Iterator end) | |
template<typename... Args> | |
NdArray (const std::vector< size_t > &shape_, const std::vector< std::string > &attr_names, Args &&... args) | |
NdArray (const std::initializer_list< size_t > &shape_) | |
NdArray (const self_type &)=default | |
NdArray (self_type &&)=default | |
NdArray & | operator= (const NdArray &)=default |
NdArray | copy () const |
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 |
T & | at (const std::vector< size_t > &coords, const std::string &attr) |
const T & | at (const std::vector< size_t > &coords, const std::string &attr) 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 |
size_t | size () const |
bool | operator== (const self_type &b) const |
bool | operator!= (const self_type &b) const |
self_type & | concatenate (const self_type &other) |
const std::vector< std::string > & | attributes () const |
Private Member Functions | |
NdArray (const self_type *other) | |
size_t | get_offset (const std::vector< size_t > &coords) const |
size_t | get_offset (std::vector< size_t > coords, const std::string &attr) 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) |
T & | at_helper (std::vector< size_t > &acc, const std::string &attr) |
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 |
std::vector< std::string > | m_attr_names |
size_t | m_size |
std::shared_ptr< ContainerInterface > | 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 Iterator<true> Euclid::NdArray::NdArray< T >::const_iterator |
typedef Iterator<false> Euclid::NdArray::NdArray< T >::iterator |
typedef NdArray<T> Euclid::NdArray::NdArray< T >::self_type |
|
virtualdefault |
Destructor.
|
explicit |
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. |
Euclid::NdArray::NdArray< T >::NdArray | ( | const std::vector< size_t > & | shape_, |
const Container< T > & | data | ||
) |
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. |
Euclid::NdArray::NdArray< T >::NdArray | ( | const std::vector< size_t > & | shape_, |
Container< T > && | data | ||
) |
Constructs a matrix and initialize it with the given data.
Container | Owns the memory used by the NdArray. It must expose the methods size() and 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. |
Euclid::NdArray::NdArray< T >::NdArray | ( | const std::vector< size_t > & | shape_, |
Iterator | begin, | ||
Iterator | end | ||
) |
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. |
Euclid::NdArray::NdArray< T >::NdArray | ( | const std::vector< size_t > & | shape_, |
const std::vector< std::string > & | attr_names, | ||
Args &&... | args | ||
) |
Constructs a matrix, giving a name to each of the items on the last dimension
attr_names | Names for the dimensions of the last axis |
shape_ | Shape for the matrix |
|
inline |
|
default |
Copy constructor
|
default |
Move constructor
|
explicitprivate |
Private constructor used for deep copies
T& Euclid::NdArray::NdArray< T >::at | ( | const std::vector< size_t > & | coords | ) |
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. |
const T& Euclid::NdArray::NdArray< T >::at | ( | const std::vector< size_t > & | coords | ) | const |
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. |
T& Euclid::NdArray::NdArray< T >::at | ( | const std::vector< size_t > & | coords, |
const std::string & | attr | ||
) |
Gets a reference to the value stored at the given coordinates.
coords | Elements coordinates, except last one |
attr | Attribute name used to determine the last coordinate |
std::out_of_range | If the number of coordinates is invalid, or any of them is out of bounds. |
const T& Euclid::NdArray::NdArray< T >::at | ( | const std::vector< size_t > & | coords, |
const std::string & | attr | ||
) | const |
Gets a constant reference to the value stored at the given coordinates.
coords | Elements coordinates, except last one |
attr | Attribute name used to determine the last coordinate |
std::out_of_range | If the number of coordinates is invalid, or any of them is out of bounds. |
T& Euclid::NdArray::NdArray< T >::at | ( | size_t | i, |
D... | rest | ||
) |
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})
). const T& Euclid::NdArray::NdArray< T >::at | ( | size_t | i, |
D... | rest | ||
) | const |
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})
).
|
private |
Helper to expand at with a variable number of arguments (base case)
|
private |
Helper to expand constant at with a variable number of arguments (base case)
|
private |
Helper to expand at with a variable number of arguments, being the last an attribute name
|
private |
Helper to expand at with a variable number of arguments
|
private |
Helper to expand constant at with a variable number of arguments
const std::vector<std::string>& Euclid::NdArray::NdArray< T >::attributes | ( | ) | const |
iterator Euclid::NdArray::NdArray< T >::begin | ( | ) |
const_iterator Euclid::NdArray::NdArray< T >::begin | ( | ) | const |
self_type& Euclid::NdArray::NdArray< T >::concatenate | ( | const self_type & | other | ) |
Concatenate to this array another one along the first axis
|
inline |
iterator Euclid::NdArray::NdArray< T >::end | ( | ) |
const_iterator Euclid::NdArray::NdArray< T >::end | ( | ) | const |
|
private |
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. |
|
private |
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, or the attribute does not exist. |
bool Euclid::NdArray::NdArray< T >::operator!= | ( | const self_type & | b | ) | const |
Two NdArrays are not equal if their shapes or their content are not equal
|
default |
Assignment
bool Euclid::NdArray::NdArray< T >::operator== | ( | const self_type & | b | ) | const |
Two NdArrays are equal if their shapes and their content are equal
self_type& Euclid::NdArray::NdArray< T >::reshape | ( | const std::vector< size_t > | new_shape | ) |
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. |
std::invalid_argument | If the array has attribute names |
self_type& Euclid::NdArray::NdArray< T >::reshape | ( | size_t | i, |
D... | rest | ||
) |
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. |
|
private |
|
private |
|
inline |
Gets the shape of the matrix.
Definition at line 286 of file NdArray.h.
References Euclid::NdArray::NdArray< T >::m_shape.
Referenced by Euclid::Table::ndArraySize(), and Euclid::NdArray::NdArray< T >::ContainerWrapper< Container >::resize().
size_t Euclid::NdArray::NdArray< T >::size | ( | ) | const |
Size of the underlying container
|
private |
Compute the stride size for each dimension
|
private |
|
private |
|
private |
Definition at line 435 of file NdArray.h.
Referenced by Euclid::NdArray::NdArray< T >::shape().
|
private |
|
private |