Documentation 6b54b78464
Loading...
Searching...
No Matches
C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols > Class Template Reference

A templated matrix/vector-like object. More...

#include <C2DContainer.hpp>

Inheritance diagram for C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >:
[legend]

Classes

class  CInnerIter
 Scalar iterator to the inner dimension of the container, read-only. More...
 
class  CInnerIterGather
 SIMD iterator to the inner dimension of the container, read-only, generic non-contiguous access. More...
 

Public Types

using Index = Index_t
 
using Scalar = Scalar_t
 

Public Member Functions

 C2DContainer () noexcept
 Default ctor.
 
 C2DContainer (const Index_t size1, const Index_t size2=1) noexcept
 Sizing ctor (no initialization of data). For matrices size1 is rows and size2 columns, for vectors size1 is lenght and size2 is ignored.
 
 C2DContainer (const C2DContainer &other) noexcept
 Copy ctor.
 
C2DContainer & operator= (const C2DContainer &other) noexcept
 Copy assignment operator, no re-allocation if sizes do not change.
 
 C2DContainer (C2DContainer &&)=default
 Move ctor, implemented by base class (if fully static works as copy).
 
C2DContainer & operator= (C2DContainer &&)=default
 Move assign operator, implemented by base class (if fully static works as copy).
 
C2DContainer & operator= (const Scalar_t &value) noexcept
 
C2DContainer & resize (const Index_t size1, const Index_t size2=1) noexcept
 Request a change of size.
 
void setConstant (const Scalar_t &value) noexcept
 Set value of all entries to "value".
 
CInnerIter innerIter (Index_t row) const noexcept
 Get a scalar iterator to the inner dimension of the container.
 
template<class T , size_t N>
CInnerIterGather< simd::Array< T, N > > innerIter (simd::Array< T, N > row) const noexcept
 Get a SIMD gather iterator to the inner dimension of the container.
 
template<class StaticContainer >
StaticContainer get (Index_t row, Index_t start=0) const noexcept
 Return copy of data in a static size container.
 
template<class StaticContainer , class T , size_t N>
StaticContainer get (simd::Array< T, N > row, Index_t start=0) const noexcept
 Return copy of data in a static size container, SIMD version.
 
Index_t cols () const noexcept
 
Index_t rows () const noexcept
 
size_t size () const noexcept
 
- Public Member Functions inherited from container_details::AccessorImpl< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >
bool empty () const noexcept
 
Scalar_t * data () noexcept
 
const Scalar_t * data () const noexcept
 
Scalar_t * begin () noexcept
 
const Scalar_t * begin () const noexcept
 
Scalar_t * end () noexcept
 
const Scalar_t * end () const noexcept
 
Index_t rows () const noexcept
 
Index_t cols () const noexcept
 
size_t size () const noexcept
 
const Scalar_t & operator() (const Index_t i, const Index_t j) const noexcept
 
Scalar_t & operator() (const Index_t i, const Index_t j) noexcept
 
const Scalar_t * operator[] (const Index_t k) const noexcept
 
Scalar_t * operator[] (const Index_t k) noexcept
 

Static Public Attributes

static constexpr StorageType Storage = Store
 
static constexpr bool IsVector = (StaticRows == 1) || (StaticCols == 1)
 
static constexpr bool IsRowMajor = (Store == StorageType::RowMajor)
 
static constexpr bool IsColumnMajor = (Store == StorageType::ColumnMajor)
 
static constexpr size_t StaticSize = StaticRows * StaticCols
 
static constexpr size_t StaticNRows = StaticRows
 
static constexpr size_t StaticNCols = StaticCols
 

Additional Inherited Members

- Protected Member Functions inherited from container_details::AccessorImpl< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >
void m_allocate (size_t sz, Index_t rows, Index_t cols) noexcept
 
void m_destroy () noexcept
 
- Protected Attributes inherited from container_details::AccessorImpl< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >
Scalar_t m_data [StaticRows *StaticCols]
 

Detailed Description

template<typename Index_t, class Scalar_t, StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
class C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >

A templated matrix/vector-like object.

See notes about MATRIX_ACCESSORS and VECTOR_ACCESSORS for how to access data. For how to construct/resize/initialize see methods below.

Template parameters:

Parameters
Index_t- The data type (built-in) for indices, signed and unsigned allowed.
Scalar_t- The stored data type, anything that can be default constructed.
Store- Mode to map 1D to 2D, row-major or column-major.
AlignSize- Desired alignment for the data in bytes, 0 means default.
StaticRows- Number of rows at compile time, for dynamic (sized at runtime) use "DynamicSize".
StaticCols- As above for columns.
Note
All accesses to data are range checked via assertions, for release compile with -DNDEBUG to avoid the associated overhead.

Member Typedef Documentation

◆ Index

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
using C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::Index = Index_t

◆ Scalar

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
using C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::Scalar = Scalar_t

Constructor & Destructor Documentation

◆ C2DContainer() [1/4]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::C2DContainer ( )
inlinenoexcept

Default ctor.

◆ C2DContainer() [2/4]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::C2DContainer ( const Index_t  size1,
const Index_t  size2 = 1 
)
inlinenoexcept

Sizing ctor (no initialization of data). For matrices size1 is rows and size2 columns, for vectors size1 is lenght and size2 is ignored.

◆ C2DContainer() [3/4]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::C2DContainer ( const C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols > &  other)
inlinenoexcept

Copy ctor.

◆ C2DContainer() [4/4]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::C2DContainer ( C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols > &&  )
default

Move ctor, implemented by base class (if fully static works as copy).

Member Function Documentation

◆ cols()

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
Index_t container_details::AccessorImpl< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::cols ( ) const
inlinenoexcept

◆ get() [1/2]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
template<class StaticContainer >
StaticContainer C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::get ( Index_t  row,
Index_t  start = 0 
) const
inlinenoexcept

Return copy of data in a static size container.

Parameters
[in]row- Row of the matrix.
[in]start- Starting column to copy the data (amount determined by container size).

◆ get() [2/2]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
template<class StaticContainer , class T , size_t N>
StaticContainer C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::get ( simd::Array< T, N >  row,
Index_t  start = 0 
) const
inlinenoexcept

Return copy of data in a static size container, SIMD version.

◆ innerIter() [1/2]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
CInnerIter C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::innerIter ( Index_t  row) const
inlinenoexcept

Get a scalar iterator to the inner dimension of the container.

◆ innerIter() [2/2]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
template<class T , size_t N>
CInnerIterGather< simd::Array< T, N > > C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::innerIter ( simd::Array< T, N >  row) const
inlinenoexcept

Get a SIMD gather iterator to the inner dimension of the container.

◆ operator=() [1/3]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer & C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::operator= ( C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols > &&  )
default

Move assign operator, implemented by base class (if fully static works as copy).

◆ operator=() [2/3]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer & C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::operator= ( const C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols > &  other)
inlinenoexcept

Copy assignment operator, no re-allocation if sizes do not change.

◆ operator=() [3/3]

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer & C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::operator= ( const Scalar_t &  value)
inlinenoexcept

◆ resize()

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
C2DContainer & C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::resize ( const Index_t  size1,
const Index_t  size2 = 1 
)
inlinenoexcept

Request a change of size.

Note
Providing an interface that allowed resizing with value could cause overloading ambiguities when Scalar_t = Index_t, so we do not. But it is possible to assign a constant on top of resize: A.resize(m,n) = x;

◆ rows()

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
Index_t container_details::AccessorImpl< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::rows ( ) const
inlinenoexcept

◆ setConstant()

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
void C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::setConstant ( const Scalar_t &  value)
inlinenoexcept

Set value of all entries to "value".

◆ size()

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
size_t container_details::AccessorImpl< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::size ( ) const
inlinenoexcept

Member Data Documentation

◆ IsColumnMajor

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
constexpr bool C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::IsColumnMajor = (Store == StorageType::ColumnMajor)
staticconstexpr

◆ IsRowMajor

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
constexpr bool C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::IsRowMajor = (Store == StorageType::RowMajor)
staticconstexpr

◆ IsVector

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
constexpr bool C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::IsVector = (StaticRows == 1) || (StaticCols == 1)
staticconstexpr

◆ StaticNCols

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
constexpr size_t C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::StaticNCols = StaticCols
staticconstexpr

◆ StaticNRows

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
constexpr size_t C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::StaticNRows = StaticRows
staticconstexpr

◆ StaticSize

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
constexpr size_t C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::StaticSize = StaticRows * StaticCols
staticconstexpr

◆ Storage

template<typename Index_t , class Scalar_t , StorageType Store, size_t AlignSize, size_t StaticRows, size_t StaticCols>
constexpr StorageType C2DContainer< Index_t, Scalar_t, Store, AlignSize, StaticRows, StaticCols >::Storage = Store
staticconstexpr

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