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

Tensor stream where all elements are zeros expects the elements on on the diagonal specified by an underlying stream. More...

#include <lin/generators/stream_diagonal.hpp>

Inheritance diagram for lin::internal::StreamDiagonal< E >:
lin::internal::Stream< StreamDiagonal< E > >

Public Types

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

Public Member Functions

constexpr StreamDiagonal (StreamDiagonal< E > const &)=default
 
constexpr StreamDiagonal (StreamDiagonal< E > &&)=default
 
constexpr StreamDiagonal< E > & operator= (StreamDiagonal< E > const &)=default
 
constexpr StreamDiagonal< E > & operator= (StreamDiagonal< E > &&)=default
 
constexpr StreamDiagonal (Stream< E > const &stream)
 Constructs a new diagonal stream from the provided vector stream. More...
 
constexpr size_t rows () const
 
constexpr size_t cols () 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...
 
- Public Member Functions inherited from lin::internal::Stream< StreamDiagonal< E > >
constexpr Stream (Stream< StreamDiagonal< E > > const &)=default
 
constexpr Stream (Stream< StreamDiagonal< E > > &&)=default
 
constexpr Stream< StreamDiagonal< E > > & operator= (Stream< StreamDiagonal< E > > const &)=default
 
constexpr Stream< StreamDiagonal< E > > & operator= (Stream< StreamDiagonal< E > > &&)=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 Attributes

Stream< E > const & _stream
 

Additional Inherited Members

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

Detailed Description

template<class E>
class lin::internal::StreamDiagonal< E >

Tensor stream where all elements are zeros expects the elements on on the diagonal specified by an underlying stream.

Template Parameters
EUnderlying vector stream.

This allows a user to sparesly define a square matrix stream where all elements evaluate to zero except for the those along the diagonal, which are specified by the elements of an underlying vector.

Note the if the underlying vector goes out of scope the diagonal stream is invalidated.

See also
internal::is_matrix
internal::is_square

Member Typedef Documentation

template<class E >
typedef traits<StreamDiagonal<E> > lin::internal::StreamDiagonal< E >::Traits

Traits information for this type.

See also
internal::traits

Constructor & Destructor Documentation

template<class E >
constexpr lin::internal::StreamDiagonal< E >::StreamDiagonal ( Stream< E > const &  stream)
inline

Constructs a new diagonal stream from the provided vector stream.

Parameters
streamUnderlying vector stream

The provided vector streams length will determine the runtime dimensions of the diagonal stream.

Changes in element values and dimensions of the underlying vector stream will be reflected in the stream itself. The underlying stream must be in scope for the stream to be valid.

Member Function Documentation

template<class E >
constexpr size_t lin::internal::StreamDiagonal< E >::rows ( ) const
inline
Returns
Number of rows.

Equals the size of the underlying vector.

template<class E >
constexpr size_t lin::internal::StreamDiagonal< E >::cols ( ) const
inline
Returns
Number of rows.

Equals the size of the underlying vector.

template<class E >
constexpr Traits::elem_t lin::internal::StreamDiagonal< 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.

Zero if off the main diagonal and specified by the underlying vector stream otherwise.

If the indices are out of bounds as defined by the stream's current dimensions, lin assertion errors will be triggered.

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

Provides read only access to tensor elements.

Parameters
iIndex.
Returns
Value of the tensor element.

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

Zero if off the main diagonal and specified by the underlying vector stream otherwise.

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


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