geomc 1.0
A c++ linear algebra template library
Public Types | Public Member Functions | Static Public Attributes | List of all members
DiagMatrix< T, M, N > Class Template Reference

A matrix with nonzero elements only along the main diagonal. More...

#include <geomc/linalg/mtxtypes/DiagMatrix.h>

Inheritance diagram for DiagMatrix< T, M, N >:
MatrixBase< T, M, N, DiagMatrix< T, M, N > >

Public Types

typedef detail::_ImplMtxReftype< DiagMatrix< T, M, N >, T >::reference reference
 
typedef T elem_t
 Element type.
 
typedef MtxSubsetIterator< const DiagMatrix< T, M, N >, const elem_tconst_iterator
 Read-only row-major iterator over matrix elements.
 
typedef const_iterator const_region_iterator
 Read-only row-major iterator over the matrix elements in a rectangular region.
 
typedef MtxRowIterator< const DiagMatrix< T, M, N >, const elem_tconst_row_iterator
 Read-only iterator over the elments of a row.
 
typedef MtxColIterator< const DiagMatrix< T, M, N >, const elem_tconst_col_iterator
 Read-only iterator over the elements of a column.
 
typedef Storage< storage_token_t, _ImplStorageObjCount< DiagMatrix< T, M, N > >::count > storagebuffer_t
 
typedef DiagMatrix< T, M, N > recurring_t
 

Public Member Functions

 DiagMatrix (index_t nrows, index_t ncols)
 
 DiagMatrix (const T src[], index_t n)
 
index_t rows () const
 
index_t cols () const
 
operator() (index_t r, index_t c) const
 
void set_identity ()
 
void set_zero ()
 
T * diagonal_begin ()
 
const T * diagonal_begin () const
 
T * diagonal_end ()
 
const T * diagonal_end () const
 
const T & diagonal (index_t i) const
 
T & diagonal (index_t i)
 
void get_storage_tokens (storage_token_t *buf) const
 
constexpr index_t storage_token_count () const
 
derived_const_row_iterator operator[] (index_t i) const
 
const_row_iterator row (index_t i) const
 
const_col_iterator col (index_t i) const
 
const_iterator begin () const
 
const_iterator end () const
 
const_region_iterator region_begin (const MatrixRegion &r) const
 
const_region_iterator region_end (const MatrixRegion &r) const
 
storagebuffer_t get_storage_token_buffer () const
 

Static Public Attributes

static constexpr index_t ROWDIM
 Row dimension template parameter.
 
static constexpr index_t COLDIM
 Column dimension template parameter.
 

Detailed Description

template<typename T, index_t M, index_t N>
class geom::DiagMatrix< T, M, N >

A matrix with nonzero elements only along the main diagonal.

Template Parameters
TElement type.
MRow dimension.
NColumn dimension.

Storage for DiagMatrixes is O(n), and operations with diagonal matrices usually benefit from the O(n) algorithmic improvement associated with their lower dimension.

Constructor & Destructor Documentation

◆ DiagMatrix() [1/2]

DiagMatrix ( index_t  nrows,
index_t  ncols 
)
inlineexplicit

Construct a new diagonal matrix.

Parameters
nrowsNumber of rows (ignored / not required if statically sized).
ncolsNumber of columns (ignored / not required if statically sized).

◆ DiagMatrix() [2/2]

DiagMatrix ( const T  src[],
index_t  n 
)
inline

Construct a new n x n diagonal matrix, with diagonal elements copied from src.

Parameters
srcArray containing diagonal elements.
nNumber of elements in src. Ignored / not required if statically sized.

Member Function Documentation

◆ begin()

const_iterator begin ( ) const
inlineinherited
Returns
A read-only random-access row major-ordered iterator over the elements of this matrix, pointing to the element at (0,0).

◆ col()

const_col_iterator col ( index_t  i) const
inlineinherited
Parameters
iIndex of column (zero-indexed)
Returns
A const iterator over the elements of column i

◆ diagonal() [1/2]

T & diagonal ( index_t  i)
inline

Return a reference to the ith diagonal element.

◆ diagonal() [2/2]

const T & diagonal ( index_t  i) const
inline

Return the ith diagonal element.

◆ diagonal_begin() [1/2]

T * diagonal_begin ( )
inline
Returns
An iterator over the elements of the main diagonal (those with matching row and column coordinates), pointing at element (0, 0).

◆ diagonal_begin() [2/2]

const T * diagonal_begin ( ) const
inline
Returns
A read-only iterator over the elements of the main diagonal (those with matching row and column coordinates), pointing at element (0, 0).

◆ diagonal_end() [1/2]

T * diagonal_end ( )
inline
Returns
An iterator over the elements of the main diagonal (those with matching row and column coordinates), pointing at the last diagonal element.

◆ diagonal_end() [2/2]

const T * diagonal_end ( ) const
inline
Returns
A read-only iterator over the elements of the main diagonal (those with matching row and column coordinates), pointing at the last diagonal element.

◆ end()

const_iterator end ( ) const
inlineinherited
Returns
A read-only random-access row major-ordered iterator over the elements of this matrix, pointing to the element just beyond the last element in the lower right corner.

◆ operator[]()

derived_const_row_iterator operator[] ( index_t  i) const
inlineinherited
Parameters
iIndex of row (zero-indexed)
Returns
A const iterator over the elements of row i

◆ region_begin()

const_region_iterator region_begin ( const MatrixRegion r) const
inlineinherited
Parameters
rThe zero-indexed region to iterate over. The upper extreme coordinates represent the index just beyond the last element to be iterated over.
Returns
A read-only, random-access, row-major iterator over the elements in region r, pointing at the first element in the region (upper left corner).

◆ region_end()

const_region_iterator region_end ( const MatrixRegion r) const
inlineinherited
Parameters
rThe zero-indexed region to iterate over. The upper extreme coordinates represent the index just beyond the last element to be iterated over.
Returns
A read-only, random-access, row-major iterator over the elements in region r, pointing at the element just beyond the last element in the region.

◆ row()

const_row_iterator row ( index_t  i) const
inlineinherited
Parameters
iIndex of row (zero-indexed)
Returns
A const iterator over the elements of row i

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