lin
Public Types | Public Member Functions | Private Attributes | List of all members
lin::internal::TensorStreamReference< D, E > Class Template Reference

Generic tensor reference with read only access. More...

#include <lin/references/tensor_stream_reference.hpp>

Inheritance diagram for lin::internal::TensorStreamReference< D, E >:
lin::internal::Stream< D > lin::internal::Dimensions< 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 TensorStreamReference (TensorStreamReference< D, E > const &)=default
 
constexpr TensorStreamReference (TensorStreamReference< D, E > &&)=default
 
constexpr TensorStreamReference< D, E > & operator= (TensorStreamReference< D, E > const &)=default
 
constexpr TensorStreamReference< D, E > & operator= (TensorStreamReference< D, E > &&)=default
 
constexpr TensorStreamReference (Stream< E > const &stream, size_t i, size_t j)
 Constructs a new reference with the provided stream and anchor point. More...
 
constexpr TensorStreamReference (Stream< E > const &stream, size_t i, size_t j, size_t r, size_t c)
 Constructs a new reference with the provided mapping, anchor point, and dimensions. More...
 
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...
 
- 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...
 
- Public Member Functions inherited from lin::internal::Dimensions< D >
constexpr Dimensions (Dimensions< D > const &)=default
 
constexpr Dimensions (Dimensions< D > &&)=default
 
constexpr Dimensions< D > & operator= (Dimensions< D > const &)=default
 
constexpr Dimensions< D > & operator= (Dimensions< D > &&)=default
 
constexpr size_t rows () const
 
constexpr size_t cols () const
 
constexpr void resize (size_t r, size_t c)
 Resizes a tensor's dimensions. More...
 

Private Attributes

Stream< E > const & _stream
 
size_t const _i
 
size_t const _j
 

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 E>
class lin::internal::TensorStreamReference< D, E >

Generic tensor reference with read only access.

Template Parameters
DDerived type.
EUnderlying referenced type.

This allows users to interpret a portion of a larger internal::Stream as an independent tensor type with user specified traits. A common use may be to treat block diagonal elements of a larger matrix independently or perform vector operations on the columns of a matrix.

It's important to note, if the underlying stream goes out of scope the reference is invalidated.

See also
internal::Stream
internal::MatrixStreamReference
internal::VectorStreamReference
internal::RowVectorStreamReference

Member Typedef Documentation

template<class D, class E>
typedef traits<D> lin::internal::TensorStreamReference< D, E >::Traits

Traits information for this type.

See also
internal::traits

Constructor & Destructor Documentation

template<class D, class E>
constexpr lin::internal::TensorStreamReference< D, E >::TensorStreamReference ( Stream< E > const &  stream,
size_t  i,
size_t  j 
)
inline

Constructs a new reference with the provided stream and anchor point.

Parameters
streamUnderlying stream.
iAnchor point row index.
jAnchor point column index.

The reference's dimensions are defaulted to the largest allowable size and the anchor point maps the top left corner of the reference to an element in the underlying stream.

The reference traits must define a type that fits within the provided mapping given the anchor point. If this is not the case, lin assertion errors will be triggered.

The anchor points specifies where the top left corner of the reference maps to in the underlying stream.

See also
internal::traits
template<class D, class E>
constexpr lin::internal::TensorStreamReference< D, E >::TensorStreamReference ( Stream< E > const &  stream,
size_t  i,
size_t  j,
size_t  r,
size_t  c 
)
inline

Constructs a new reference with the provided mapping, anchor point, and dimensions.

Parameters
mappingUnderlying stream.
iAnchor point row index.
jAnchor point column index.
rReference row dimension.
cReference column dimension.

The anchor point maps the top left corner of the reference to an element in the underlying stream.

The reference traits must define a type that fits within the provided mapping given the anchor point. If this is not the case, lin assertion errors will be triggered.

The anchor points specifies where the top left corner of the reference maps to in the underlying stream.

Lin assertions errors will be triggered if the requested dimensions aren't possible given the reference's traits.

See also
internal::traits

Member Function Documentation

template<class D, class E>
constexpr Traits::elem_t lin::internal::TensorStreamReference< D, E >::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 the indices are out of bounds as defined by the reference's current dimensions, lin assertion errors will be triggered.

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, class E>
constexpr Traits::elem_t lin::internal::TensorStreamReference< D, E >::operator() ( size_t  i) const
inline

Provides read only 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.

If the index is out of bounds as defined by the tensor's current size, lin assertion errors will be triggered.

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

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