Alexandria
2.14.1
Please provide a description of the project.
|
The NdArray module provides a multidimensional container storing its elements contiguously in memory in row-major order. For instance, a 3D array with the shape (3,2,4) contains 24 elements.
The order in memory is for that array would be:
The usage of this class is fairly straight forward. You need to define it specifying at least the contained type, and pass to the constructor either a shape, or a shape and initial data.
For convenience, you can pass the shape as a vector of size_t
, or as a initializer list.
The individual elements can be accessed with the method at
. Similarly to the constructor, it accepts either the axes as a list of parameters, or as a vector of size_t.
The version that accepts a list of parameters ultimately generates a call to the second via metaprogramming, so they are fully equivalent.
To get the array shape, just use the shape
method.
You can also get the total size (number of elements), and a reference to the underlying container.
Last, there is an overload of the operator <<
for std::ostream
. This can be useful for debugging, but it is also necessary for the implementation of Euclid::Table::AsciiWriter, as it relies on the existence of this operator (technically, boost::lexical_cast
does). The output has the form <shape>values
.