deal.II version GIT relicensing-1989-gd7a2c90e4e 2024-10-14 01:50:00+00:00
|
Go to the source code of this file.
Typedefs | |
template<typename T , std::size_t... Ns> | |
using | ndarray = typename internal::ndarray::HelperArray< T, Ns... >::type |
using ndarray = typename internal::ndarray::HelperArray<T, Ns...>::type |
A (variadic template) type alias for conveniently defining multidimensional std::arrays.
The problem we try to address with the type alias is the following. Suppose you want to create a multdimensional array of doubles of, for example, rank 3, with sizes 2, 3, 4 for the first, middle, and last index. Then using C-style arrays you could simply write
There are a number of good reasons why using C-style arrays is generally discouraged (ranging from incompatibilities with STL functions requiring awkward wrappers, surprises when comparing for equality, etc.). If you want to do the same, however, using the more modern (and encouraged) std::array
class, then you would have to declare
The repetitions of std::array
look awkward and, worse, the index ranges have reversed: the leftmost index has range [0,2), the middle index has range [0,3) and the rightmost index has range [0,4). We address this issue by providing a class ndarray that allows to you declare the above stacked std::array
type by simply writing:
using
declaration). It is not a deal.II specific class, but merely a helper to cleanly define multidimensional arrays realized by "stacked" std::array
classes.