A tensor - a multi-dimensional tagged generalization of vector/matrix. More...
#include <tagged.hpp>
Public Types | |
using | view_type = extract_tensor_view< E, TL ...> |
using | const_view_type = extract_tensor_view< const E, TL ...> |
Public Member Functions | |
template<tag ... TL2> requires (sizeof...(TL2) == sizeof...(TL)) | |
tensor_class (const range_class< TL2 ... > &rng) | |
Initialize the tensor_class to a size defined by a range_class. | |
template<tag ... TL2> requires (sizeof...(TL2) == sizeof...(TL)) | |
tensor_class (const range_class< TL2 ... > &rng, const E &e) noexcept | |
Initialize the tensor_class to a size defined by a range_class. | |
view_type | view () |
Return tensor_view acting as a reference to the complete tensor_class. | |
const_view_type | view () const |
Return tensor_view acting as a const reference to the complete tensor_class. | |
template<tag ... TL2> requires (sizeof...(TL2) < sizeof...(TL)) && impl::subset_selector< tag_list< TL2...>, tag_list< TL...>> | |
auto | operator[] (const index_class< TL2 ... > &i) |
Extract a reference to a sub-space of this tensor. | |
template<tag ... TL2> requires (sizeof...(TL2) < sizeof...(TL)) && impl::subset_selector< tag_list< TL2...>, tag_list< TL...>> | |
auto | operator[] (const index_class< TL2 ... > &i) const |
Extract an immutable reference to a sub-space of this tensor. | |
template<tag ... TL2> requires (sizeof...(TL2) == sizeof...(TL)) && impl::subset_selector< tag_list< TL2...>, tag_list< TL...>> | |
E & | operator[] (const index_class< TL2... > &i) |
Access an element of this tensor. | |
template<tag ... TL2> requires (sizeof...(TL2) == sizeof...(TL)) && impl::subset_selector< tag_list< TL2...>, tag_list< TL...>> | |
const E & | operator[] (const index_class< TL2... > &i) const |
Read an element of this tensor. | |
const range_class< TL ... > & | range () const |
The range corresponding to this tensor. | |
E * | data () |
A pointer to the beginning of the array containing the data. | |
const E * | data () const |
A const pointer to the beginning of the array containing the data. | |
E * | flat_data () |
A pointer to the beginning of the array containing the data. | |
const E * | flat_data () const |
A const pointer to the beginning of the array containing the data. | |
A tensor - a multi-dimensional tagged generalization of vector/matrix.
The order of tags in the template argument list defines the layout. The right-most tag becomes the inner-most dimension (with contiguously stored elements).
The tensor contains precomputed multipliers for each dimension so that indexing in each dimension works in constant time.
Optimization: If K rightmost tags have statically defined range, the multipliers of the righmost (K+1) dimensions are precomputed statically and not stored as run-time data inside the class. The same precomputation is applied in every tensor_view referencing this tensor_class.
E | Element type |
...TL | Tag list |
|
inlineexplicit |
Initialize the tensor_class to a size defined by a range_class.
...TL2 | Tag list |
rng | Multi-tagged range |
|
inlinenoexcept |
Initialize the tensor_class to a size defined by a range_class.
...TL2 | Tag list |
rng | Multi-tagged range |
e | Initial values for all elements |
|
inline |
A pointer to the beginning of the array containing the data.
Available only if the tensor_view is single-dimensional
|
inline |
A const
pointer to the beginning of the array containing the data.
Available only if the tensor_view is single-dimensional
const
pointer to the underlying contiguous data array
|
inline |
A pointer to the beginning of the array containing the data.
It is the responsibility of the user to properly analyze the layout of the data
|
inline |
A const
pointer to the beginning of the array containing the data.
It is the responsibility of the user to properly analyze the layout of the data
const
pointer to the underlying single-dimensional data array
|
inline |
Extract a reference to a sub-space of this tensor.
The new sub-space is defined by fixing one or more indexes defined by the tagged (multi-dimensional) index argument to the operator
...TL2 | Tag list |
i | A (multi-)tagged index |
|
inline |
Extract an immutable reference to a sub-space of this tensor.
The new sub-space is defined by fixing one or more indexes defined by the tagged (multi-dimensional) index argument to the operator
...TL2 | Tag list |
i | A (multi-)tagged index |
|
inline |
Access an element of this tensor.
...TL2 | Tag list |
i | A (multi-)tagged index covering (in any order) all the dimensions of this tensor |
|
inline |
Read an element of this tensor.
...TL2 | Tag list |
i | A (multi-)tagged index covering (in any order) all the dimensions of this tensor |
const
reference to the element
|
inline |
The range corresponding to this tensor.
|
inline |
Return tensor_view acting as a reference to the complete tensor_class.
|
inline |
Return tensor_view acting as a const
reference to the complete tensor_class.