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

Member array backed tensor. More...

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

Inheritance diagram for lin::internal::Tensor< D >:
lin::internal::Base< D > lin::internal::Mapping< D > lin::internal::Dimensions< D > lin::internal::Stream< D >

Public Types

typedef traits< D > Traits
 Traits information for this type. More...
 
- Public Types inherited from lin::internal::Base< D >
typedef traits< D > Traits
 Traits information for this type. More...
 
- Public Types inherited from lin::internal::Mapping< D >
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 Tensor (Tensor< D > const &)=default
 
constexpr Tensor (Tensor< D > &&)=default
 
constexpr Tensor< D > & operator= (Tensor< D > const &)=default
 
constexpr Tensor< D > & operator= (Tensor< D > &&)=default
 
constexpr Tensor ()
 Constructs a new tensor with zeros initialized elements and the largest allowable dimensions. More...
 
constexpr Tensor (size_t r, size_t c)
 Constructs a tensor with zeros initialized elements and the requested dimensions. More...
 
template<typename T >
constexpr Tensor (std::initializer_list< T > const &list)
 Constructs a tensor with elements initialized from an initializer list. More...
 
template<typename T >
constexpr Tensor (size_t r, size_t c, std::initializer_list< T > const &list)
 Constructs a tensor with elements initialized from an initializer list and the requested dimensions. More...
 
template<class C >
constexpr Tensor (Stream< C > const &s)
 Constructs a tensor by copying in dimensions and elements from another tensor stream. More...
 
constexpr Traits::elem_tdata ()
 Retrives a pointer to the element backing array. More...
 
- Public Member Functions inherited from lin::internal::Base< D >
constexpr Base (Base< D > const &)=default
 
constexpr Base (Base< D > &&)=default
 
constexpr Base< D > & operator= (Base< D > const &)=default
 
constexpr Base< D > & operator= (Base< D > &&)=default
 
constexpr Traits::elem_tdata ()
 Retrives a pointer to the element backing array. More...
 
constexpr Traits::elem_t const * data () const
 Retrives a constant pointer to the element backing array. More...
 
constexpr Traits::elem_toperator() (size_t i, size_t j)
 Provides read and write access to tensor elements. More...
 
constexpr Traits::elem_toperator() (size_t i)
 Provides read and write access to tensor elements. More...
 
- Public Member Functions inherited from lin::internal::Mapping< D >
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...
 
- 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

Traits::elem_t elems [Traits::max_size] = { typename Traits::elem_t(0) }
 

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::Tensor< D >

Member array backed tensor.

Template Parameters
DDerived type.

This is the most commonly used implementation of the internal::Base interface. Tensor elements are stored contiguously in a member backing array in row major order.

This type is directly derived by the user facing Matrix, RowVector, and Vector types.

See also
internal::Base
Matrix
RowVector
Vector

Member Typedef Documentation

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

Traits information for this type.

See also
internal::traits

Constructor & Destructor Documentation

template<class D>
constexpr lin::internal::Tensor< D >::Tensor ( )
inline

Constructs a new tensor with zeros initialized elements and the largest allowable dimensions.

See also
internal::traits
template<class D>
constexpr lin::internal::Tensor< D >::Tensor ( size_t  r,
size_t  c 
)
inline

Constructs a tensor with zeros initialized elements and the requested dimensions.

Parameters
rInitial row dimension.
cInitial column dimesnion.
See also
internal::traits
template<class D>
template<typename T >
constexpr lin::internal::Tensor< D >::Tensor ( std::initializer_list< T > const &  list)
inline

Constructs a tensor with elements initialized from an initializer list.

Template Parameters
TElement type of the initializer list.
Parameters
listInitializer list.

The tensor dimensions defaults to the largest allowable dimensions and the initializer list must be assignable to a tensor of this type.

See also
internal::traits
internal::Mapping::operator=(std::initializer_list<T> const &)
internal::Tensor::Tensor(size_t, size_t, std::initializer_list<T> const &)
template<class D>
template<typename T >
constexpr lin::internal::Tensor< D >::Tensor ( size_t  r,
size_t  c,
std::initializer_list< T > const &  list 
)
inline

Constructs a tensor with elements initialized from an initializer list and the requested dimensions.

Template Parameters
TElement type of the initializer list.
Parameters
rInitial row dimension.
cInitial column dimensions.
listInitializer list.

The initializer list must be assignable to a tensor of this type.

See also
internal::traits
internal::Mapping::operator=(std::initializer_list<T> const &)
internal::Tensor::Tensor(std::initializer_list<T> const &)
template<class D>
template<class C >
constexpr lin::internal::Tensor< D >::Tensor ( Stream< C > const &  s)
inline

Constructs a tensor by copying in dimensions and elements from another tensor stream.

Template Parameters
COther derived type.
Parameters
sOther tensor stream.

The tensor will automatically attempt to resize to the dimensions of the other tensor stream.

The stream must be assignable to a tensor of this type.

See also
internal::Mapping::operator=(Stream<C> const &)

Member Function Documentation

template<class D>
constexpr Traits::elem_t* lin::internal::Tensor< D >::data ( )
inline

Retrives a pointer to the element backing array.

Returns
Pointer to the backing array.

The elements of the tensor are layed out in row major order in the backing array. They are stored continguously in memory.


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