asgn
 
Loading...
Searching...
No Matches
tagged::tensor_view< E, TL > Class Template Reference

A reference to a sub-space of a tensor. More...

#include <tagged.hpp>

Public Member Functions

const range_trange () const
 The range corresponding to the sub-space.
 
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 a sub-space of this sub-space.
 
template<tag ... TL2>
requires (sizeof...(TL2) == sizeof...(TL)) && impl::subset_selector< tag_list< TL2...>, tag_list< TL...>>
E & operator[] (const index_class< TL2 ... > &i) const
 Access an element of this sub-space.
 
E * data () const
 A pointer to the beginning of the array containing the sub-space data.
 
E * flat_data () const
 A pointer to the element at the position defined by the lowermost index values of all dimensions of the tensor_view.
 
template<tag T2>
std::size_t dim_size () const
 Return the sub-space size in a dimension specified by a tag.
 
template<std::size_t I2>
std::size_t dim_size () const
 Return the sub-space size in a dimension specified by an index.
 

Static Public Member Functions

template<tag T2>
requires impl::has_static_multiplier< pick< selector<T2>, TL...>>
static constexpr std::size_t dim_multiplier ()
 Return the multiplier associated with the dimension specified by a tag.
 
template<std::size_t I2>
requires impl::has_static_multiplier< pick_index< I2, TL...>>
static constexpr std::size_t dim_multiplier ()
 Return the multiplier associated with the dimension specified by an index.
 

Static Public Attributes

static constexpr std::size_t dimensions = sizeof...(TL)
 The number of dimensions of this tensor-view.
 

Detailed Description

template<typename E, tag ... TL>
class tagged::tensor_view< E, TL >

A reference to a sub-space of a tensor.

The tensor_view type shall newer be used directly because the tag list is used to pass layout information from the tensor_class being referenced.

Instead, always use an auto variable to store tensor_view returned from an operator[]

Template Parameters
EElement type, possibly const
...TLTag list

Member Function Documentation

◆ data()

template<typename E, tag ... TL>
E * tagged::tensor_view< E, TL >::data ( ) const
inline

A pointer to the beginning of the array containing the sub-space data.

Available only if the tensor_view is single-dimensional and the dimension corresponds to the right-most tag of the tensor_class being referenced (i.e. when the data elements of the view are stored contiguously)

Returns
A (possibly modifiable) pointer to the associated contiguous data sub-array in the associated tensor_class

◆ dim_multiplier() [1/2]

template<typename E, tag ... TL>
template<tag T2>
requires impl::has_static_multiplier< pick< selector<T2>, TL...>>
static constexpr std::size_t tagged::tensor_view< E, TL >::dim_multiplier ( )
inlinestaticconstexpr

Return the multiplier associated with the dimension specified by a tag.

The multiplier must be used to multiply the value of a 0-based (non-tagged) index in the specified dimension when accessing the elements using the pointer returned by flat_data

Template Parameters
T2Selector tag
Returns
The multiplier

◆ dim_multiplier() [2/2]

template<typename E, tag ... TL>
template<std::size_t I2>
requires impl::has_static_multiplier< pick_index< I2, TL...>>
static constexpr std::size_t tagged::tensor_view< E, TL >::dim_multiplier ( )
inlinestaticconstexpr

Return the multiplier associated with the dimension specified by an index.

The multiplier must be used to multiply the value of a 0-based (non-tagged) index in the specified dimension when accessing the elements using the pointer returned by flat_data

Template Parameters
I2Dimension index
Returns
The multiplier

◆ dim_size() [1/2]

template<typename E, tag ... TL>
template<tag T2>
std::size_t tagged::tensor_view< E, TL >::dim_size ( ) const
inline

Return the sub-space size in a dimension specified by a tag.

Template Parameters
T2Selector tag
Returns
The size

◆ dim_size() [2/2]

template<typename E, tag ... TL>
template<std::size_t I2>
std::size_t tagged::tensor_view< E, TL >::dim_size ( ) const
inline

Return the sub-space size in a dimension specified by an index.

Template Parameters
I20-based dimension index
Returns
The size

◆ flat_data()

template<typename E, tag ... TL>
E * tagged::tensor_view< E, TL >::flat_data ( ) const
inline

A pointer to the element at the position defined by the lowermost index values of all dimensions of the tensor_view.

It is the responsibility of the user to properly analyze the layout of the data using the dimensions, dim_size, and dim_multiplier members

Returns
A (possibly modifiable) pointer into the associated tensor_class data

◆ operator[]() [1/2]

template<typename E, tag ... TL>
template<tag ... TL2>
requires (sizeof...(TL2) < sizeof...(TL)) && impl::subset_selector< tag_list< TL2...>, tag_list< TL...>>
auto tagged::tensor_view< E, TL >::operator[] ( const index_class< TL2 ... > & i) const
inline

Extract a sub-space of this sub-space.

The new sub-space is defined by fixing one or more indexes defined by the tagged (multi-dimensional) index argument to the operator

Template Parameters
...TL2Tag list
Parameters
iA (multi-)tagged index
Returns
A tensor_view

◆ operator[]() [2/2]

template<typename E, tag ... TL>
template<tag ... TL2>
requires (sizeof...(TL2) == sizeof...(TL)) && impl::subset_selector< tag_list< TL2...>, tag_list< TL...>>
E & tagged::tensor_view< E, TL >::operator[] ( const index_class< TL2 ... > & i) const
inline

Access an element of this sub-space.

Template Parameters
...TL2Tag list
Parameters
iA (multi-)tagged index covering (in any order) all the dimensions of this tensor_view
Returns
A (possibly modifiable) reference to the element

◆ range()

template<typename E, tag ... TL>
const range_t & tagged::tensor_view< E, TL >::range ( ) const
inline

The range corresponding to the sub-space.

Returns

The documentation for this class was generated from the following file: