Volume Cartographer 2.27.0
|
Dynamically-allocated N-Dimensional Array. More...
#include <vc/core/types/NDArray.hpp>
Public Types | |
using | Container = std::vector< T > |
using | IndexType = typename Container::size_type |
using | Extent = std::vector< IndexType > |
using | Index = std::vector< IndexType > |
using | iterator = typename Container::iterator |
using | const_iterator = typename Container::const_iterator |
Public Member Functions | |
NDArray (std::size_t n) | |
Default constructor. More... | |
NDArray (std::size_t n, Extent e) | |
Constructor with dimensions. More... | |
template<typename... Es> | |
NDArray (std::size_t n, Es... extents) | |
template<typename InputIt > | |
NDArray (std::size_t n, Extent e, InputIt first, InputIt last) | |
Constructor with range initialization. More... | |
void | setExtents (Extent e) |
Set the extent of the array's dimensions. More... | |
template<typename... Es> | |
void | setExtents (Es... extents) |
auto | dims () const -> std::size_t |
Get the number of dimensions of the array. More... | |
auto | extents () const -> Extent |
Get the extent (size) of the array's dimensions. More... | |
auto | size () const -> std::size_t |
Get the total number of elements in the array. More... | |
auto | operator() (Index index) -> T & |
Per-element access. More... | |
auto | operator() (Index index) const -> const T & |
template<typename... Is> | |
auto | operator() (Is... indices) -> T & |
template<typename... Is> | |
auto | operator() (Is... indices) const -> const T & |
auto | slice (IndexType index) -> NDArray |
Get slice of array by dropping highest dimension. More... | |
auto | as_vector () -> Container |
Return copy of raw data. More... | |
auto | as_vector () const -> Container |
auto | data () -> typename Container::value_type * |
Get a pointer to the start of the underlying data. More... | |
auto | data () const -> typename Container::value_type * |
auto | begin () -> iterator |
Return an iterator that points to the first element in the array. More... | |
auto | begin () const -> const_iterator |
Return an iterator that points to the first element in the array. More... | |
auto | end () -> iterator |
Return an iterator that points to the past-the-end element in the array. More... | |
auto | end () const -> const_iterator |
Return an iterator that points to the past-the-end element in the array. More... | |
auto | front () -> T & |
Return a reference to the first element in the array. More... | |
auto | front () const -> const T & |
Return a reference to the first element in the array. More... | |
auto | back () -> T & |
Return a reference to the last element in the array. More... | |
auto | back () const -> const T & |
Return a reference to the last element in the array. More... | |
Static Public Member Functions | |
static void | Flatten (NDArray &a, std::size_t dim) |
Flatten an array by dropping a dimension and appending the data to the next highest dimension. More... | |
Private Member Functions | |
void | resize_container_ () |
auto | index_to_data_index_ (Index i) const -> IndexType |
Private Attributes | |
std::size_t | dim_ {1} |
Extent | extents_ |
Container | data_ |
Dynamically-allocated N-Dimensional Array.
Array is immediately allocated upon construction.
Modified from origin project YANDA: https://github.com/csparker247/yanda
T | Type of array elements |
Definition at line 28 of file NDArray.hpp.
using volcart::NDArray< T >::const_iterator = typename Container::const_iterator |
Const iterator type
Definition at line 42 of file NDArray.hpp.
using volcart::NDArray< T >::Container = std::vector<T> |
Storage container alias
Definition at line 32 of file NDArray.hpp.
using volcart::NDArray< T >::Extent = std::vector<IndexType> |
Extents type
Definition at line 36 of file NDArray.hpp.
using volcart::NDArray< T >::Index = std::vector<IndexType> |
N-Dim Array Index type
Definition at line 38 of file NDArray.hpp.
using volcart::NDArray< T >::IndexType = typename Container::size_type |
Container index type
Definition at line 34 of file NDArray.hpp.
using volcart::NDArray< T >::iterator = typename Container::iterator |
Iterator type
Definition at line 40 of file NDArray.hpp.
|
inlineexplicit |
Default constructor.
Definition at line 46 of file NDArray.hpp.
|
inlineexplicit |
Constructor with dimensions.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 49 of file NDArray.hpp.
|
inlineexplicit |
Definition at line 60 of file NDArray.hpp.
|
inlineexplicit |
Constructor with range initialization.
Definition at line 71 of file NDArray.hpp.
|
inline |
Return copy of raw data.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 174 of file NDArray.hpp.
|
inline |
Definition at line 177 of file NDArray.hpp.
|
inline |
Return a reference to the last element in the array.
Definition at line 212 of file NDArray.hpp.
|
inline |
Return a reference to the last element in the array.
Definition at line 215 of file NDArray.hpp.
|
inline |
Return an iterator that points to the first element in the array.
Definition at line 191 of file NDArray.hpp.
|
inline |
Return an iterator that points to the first element in the array.
Definition at line 194 of file NDArray.hpp.
|
inline |
Get a pointer to the start of the underlying data.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 180 of file NDArray.hpp.
|
inline |
Definition at line 183 of file NDArray.hpp.
|
inline |
Get the number of dimensions of the array.
Definition at line 113 of file NDArray.hpp.
|
inline |
Return an iterator that points to the past-the-end element in the array.
Definition at line 200 of file NDArray.hpp.
|
inline |
Return an iterator that points to the past-the-end element in the array.
Definition at line 203 of file NDArray.hpp.
|
inline |
Get the extent (size) of the array's dimensions.
Definition at line 116 of file NDArray.hpp.
|
inlinestatic |
Flatten an array by dropping a dimension and appending the data to the next highest dimension.
Definition at line 222 of file NDArray.hpp.
|
inline |
Return a reference to the first element in the array.
Definition at line 206 of file NDArray.hpp.
|
inline |
Return a reference to the first element in the array.
Definition at line 209 of file NDArray.hpp.
|
inlineprivate |
Convert item index to data index
Definition at line 268 of file NDArray.hpp.
|
inline |
Per-element access.
Definition at line 124 of file NDArray.hpp.
|
inline |
Definition at line 134 of file NDArray.hpp.
|
inline |
Definition at line 144 of file NDArray.hpp.
|
inline |
Definition at line 151 of file NDArray.hpp.
|
inlineprivate |
Resize the data container to current extents
Definition at line 254 of file NDArray.hpp.
|
inline |
Definition at line 107 of file NDArray.hpp.
|
inline |
Set the extent of the array's dimensions.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 95 of file NDArray.hpp.
|
inline |
Get the total number of elements in the array.
Definition at line 119 of file NDArray.hpp.
|
inline |
Get slice of array by dropping highest dimension.
Definition at line 157 of file NDArray.hpp.
|
private |
Data storage
Definition at line 251 of file NDArray.hpp.
|
private |
Number of dimensions
Definition at line 247 of file NDArray.hpp.
|
private |
Dimension extents
Definition at line 249 of file NDArray.hpp.