lin
Public Types | Public Member Functions | Private Types | List of all members
lin::internal::Mapping< D > Class Template Reference

Tensor interface providing read and write access to elements. More...

#include <lin/core/types/mapping.hpp>

Inheritance diagram for lin::internal::Mapping< D >:
lin::internal::Stream< D > lin::internal::Base< D > lin::internal::TensorMappingReference< D, E > lin::internal::Tensor< D > lin::internal::TensorView< D >

Public Types

typedef traits< D > Traits
 Traits information for this type. More...
 
- Public Types inherited from lin::internal::Stream< D >
typedef traits< D > Traits
 Traits information for this type. More...
 

Public Member Functions

constexpr Mapping (Mapping< D > const &)=default
 
constexpr Mapping (Mapping< D > &&)=default
 
constexpr Mapping< D > & operator= (Mapping< D > const &)=default
 
constexpr Mapping< D > & operator= (Mapping< D > &&)=default
 
constexpr Traits::elem_toperator() (size_t i, size_t j)
 Provides read and write access to tensor elements. More...
 
constexpr Traits::elem_t operator() (size_t i, size_t j) const
 Provides read only access to tensor elements. More...
 
constexpr Traits::elem_toperator() (size_t i)
 Provides read and write access to tensor elements. More...
 
constexpr Traits::elem_t operator() (size_t i) const
 Provides read only access to tensor elements. More...
 
constexpr Traits::elem_toperator[] (size_t i)
 Provides read and write access to tensor elements. More...
 
constexpr Traits::elem_t operator[] (size_t i) const
 Provides read only access to tensor elements. More...
 
template<typename T , std::enable_if_t< is_detected< assign_expr, typename Traits::elem_t, T >::value, size_t > = 0>
constexpr D & operator= (std::initializer_list< T > const &list)
 Copy an initializer list's elements into the tensor's elements. More...
 
template<class C , std::enable_if_t< conjunction< have_same_dimensions< D, C >, is_detected< assign_expr, typename Traits::elem_t, traits_elem_t< C >> >::value, size_t > = 0>
constexpr D & operator= (Stream< C > const &s)
 Copy another tensor's elements into this tenosr's elements. More...
 
- Public Member Functions inherited from lin::internal::Stream< D >
constexpr Stream (Stream< D > const &)=default
 
constexpr Stream (Stream< D > &&)=default
 
constexpr Stream< D > & operator= (Stream< D > const &)=default
 
constexpr Stream< D > & operator= (Stream< D > &&)=default
 
constexpr size_t rows () const
 
constexpr size_t cols () const
 
constexpr size_t size () const
 
constexpr Traits::elem_t operator() (size_t i, size_t j) const
 Provides read only access to tensor elements. More...
 
constexpr Traits::elem_t operator() (size_t i) const
 Provides read only access to tensor elements. More...
 
constexpr Traits::elem_t operator[] (size_t i) const
 Provides read only access to tensor elements. More...
 
constexpr Traits::eval_t eval () const
 Forces evaluation of this stream to a value backed type. More...
 

Private Types

template<typename T , typename U >
using assign_expr = decltype(std::declval< T & >()=std::declval< U & >())
 

Additional Inherited Members

- Protected Member Functions inherited from lin::internal::Stream< D >
constexpr D & derived ()
 
constexpr D const & derived () const
 

Detailed Description

template<class D>
class lin::internal::Mapping< D >

Tensor interface providing read and write access to elements.

Template Parameters
DDerived type.

This is the second of the three main entry points on the lin inheritance tree after internal::Stream.

Here, read and write element access is provided and the most frequently used assignment operators are defined.

The main purpose is to provide an interface that supporst block references.

See also
internal::Stream
internal::Base

Member Typedef Documentation

template<class D>
typedef traits<D> lin::internal::Mapping< D >::Traits

Traits information for this type.

See also
internal::traits

Member Function Documentation

template<class D>
constexpr Traits::elem_t& lin::internal::Mapping< D >::operator() ( size_t  i,
size_t  j 
)
inline

Provides read and write access to tensor elements.

Parameters
iRow index.
jColumn index.
Returns
Reference to the tensor element.
template<class D>
constexpr Traits::elem_t lin::internal::Mapping< D >::operator() ( size_t  i,
size_t  j 
) const
inline

Provides read only access to tensor elements.

Parameters
iRow index.
jColumn index.
Returns
Value of the tensor element.

If accessing data from a lazily evaluation tensor operation, you may want to consider for the creation of a value backed type to reduce overhead.

See also
internal::Stream::eval
template<class D>
constexpr Traits::elem_t& lin::internal::Mapping< D >::operator() ( size_t  i)
inline

Provides read and write access to tensor elements.

Parameters
iIndex
Returns
Reference to the tensor element.

Element access proceeds as if all the elements of the tensor stream were flattened into an array in row major order.

template<class D>
constexpr Traits::elem_t lin::internal::Mapping< D >::operator() ( size_t  i) const
inline

Provides read only access to tensor elements.

Parameters
iIndex.
Returns
Value of the tensor elements.

Element access proceeds as if all the elements of the tensor stream were flattened into an array in row major order.

template<class D>
constexpr Traits::elem_t& lin::internal::Mapping< D >::operator[] ( size_t  i)
inline

Provides read and write access to tensor elements.

Parameters
iIndex
Returns
Reference to the tensor element.

Element access proceeds as if all the elements of the tensor stream were flattened into an array in row major order.

template<class D>
constexpr Traits::elem_t lin::internal::Mapping< D >::operator[] ( size_t  i) const
inline

Provides read only access to tensor elements.

Parameters
iIndex.
Returns
Value of the tensor elements.

Element access proceeds as if all the elements of the tensor stream were flattened into an array in row major order.

template<class D>
template<typename T , std::enable_if_t< is_detected< assign_expr, typename Traits::elem_t, T >::value, size_t > = 0>
constexpr D& lin::internal::Mapping< D >::operator= ( std::initializer_list< T > const &  list)
inline

Copy an initializer list's elements into the tensor's elements.

Parameters
listInitializer list.
Returns
Reference to the derived object.

The elements in the initializer need to be specified in row major order.

If the length of the initializer list doesn't match the current size of the tensor, a lin assertion error will be triggered.

template<class D>
template<class C , std::enable_if_t< conjunction< have_same_dimensions< D, C >, is_detected< assign_expr, typename Traits::elem_t, traits_elem_t< C >> >::value, size_t > = 0>
constexpr D& lin::internal::Mapping< D >::operator= ( Stream< C > const &  s)
inline

Copy another tensor's elements into this tenosr's elements.

Parameters
sOther tensor stream.
Returns
Reference to the derived object.

This function is only enable if both tensor have the same compile time dimensions and the other element's type can be assinged to this tensor's element type.

If the dimensions of the tensor don't match at runtime, a lin assertion error will be triggered.

See also
internal::have_same_dimensions

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