TBCI Numerical high perf. C++ Library 2.8.0
CRMatrix< T > Class Template Reference

C++ class for sparse matrices using compressed row storage. More...

#include <crmatrix.h>

Inheritance diagram for CRMatrix< T >:
Collaboration diagram for CRMatrix< T >:

Public Types

typedef T value_type
typedef T element_type
typedef T aligned_value_type TALIGN(MIN_ALIGN2)

Public Member Functions

 CRMatrix ()
 CRMatrix (unsigned int rows, unsigned int columns)
 CRMatrix (const CRMatrix< T > &m)
 CRMatrix (const Matrix< T > &mat)
 ~CRMatrix ()
CRMatrix< T > & clear ()
 set all elements defined to zero
CRMatrix< T > & fill (const T &)
 set all defined element to a val
CRMatrix< T > & setunit (const T &=(T) 1)
 set CSCMatrix to val times the unit matrix
const Toperator() (unsigned int row, unsigned int column) const
 element access (read)
const Tget (unsigned int row, unsigned int column) const
CRMatrix< T > & setval (const T &z, unsigned int row, unsigned int column)
 element access (write)
Tsetval (unsigned int row, unsigned int column)
Toperator() (unsigned int row, unsigned int column)
TVector< Tget_row (unsigned int row) const
void set_row (const Vector< T > &v, unsigned int row)
void set_row (const TVector< T > &tv, unsigned int row)
void set_row (const TSVector< T > &tsv, unsigned int row)
void set_row (T *value, unsigned int row, unsigned int count, unsigned int *index)
unsigned int rows () const
unsigned int columns () const
unsigned int size () const
void resize (unsigned int newRows, unsigned int newColumns)
CRMatrix< T > & operator= (const CRMatrix< T > &m)
bool operator== (const CRMatrix< T > &m) const
bool operator!= (const CRMatrix< T > &m) const
CRMatrix< Toperator- () const
TVector< Toperator* (const Vector< T > &v) const
TVector< Toperator* (const TVector< T > &tv) const
TVector< Toperator* (TSVector< T > &tsv) const
void MatVecMult (Vector< T > &res, const Vector< T > &v) const
void MatVecMult (T *v, T *res)
TVector< TtransMult (const Vector< T > &v) const
TVector< TtransMult (const TVector< T > &tv) const
TVector< TtransMult (const TSVector< T > &tsv) const
CRMatrix< Toperator* (const T &z) const
CRMatrix< T > & operator*= (const T &z)
CRMatrix< Toperator/ (const T &z) const
CRMatrix< T > & operator/= (const T &z)
CRMatrix< Tmult (const T &z) const
CRMatrix< T > & swap (CRMatrix< T > &)
CRMatrix< Ttransposed_copy () const
 Inefficient! Use transMult if possible.
CRMatrix< T > & transpose ()
Public Member Functions inherited from Matrix_Sig< T >
 Matrix_Sig ()
 ~Matrix_Sig ()
tbci_traits< T >::const_refval_type operator() (const unsigned, const unsigned) const
 ro access
Toperator() (const unsigned, const unsigned)
 rw access
Matrix_Sig< T > & fill (const T &)
Matrix_Sig< T > & setunit (const T &=(T) 1)
Matrix_Sig< T > & clear ()
TVector< Toperator* (const Vector_Sig< T > &) const
TVector< TtransMult (const Vector_Sig< T > &) const
unsigned int rows () const
unsigned int columns () const

Static Public Member Functions

static const char * mat_info ()
Static Public Member Functions inherited from Matrix_Sig< T >
static const char * mat_info ()

Protected Member Functions

void allocate (unsigned int rows, unsigned int columns)
void destroy ()
void copy (const CRMatrix< T > &m)

Protected Attributes

unsigned int n_rows
unsigned int n_cols
unsigned int * rowSize
unsigned int ** colIndex
T ** comp
T dummy

Friends

STD__ ostream & operator<<FGD (STD__ ostream &stream, const CRMatrix< T > &m)

Detailed Description

template<typename T>
class CRMatrix< T >

C++ class for sparse matrices using compressed row storage.

Definition at line 63 of file crmatrix.h.

Member Typedef Documentation

◆ element_type

template<typename T>
typedef T CRMatrix< T >::element_type

Definition at line 80 of file crmatrix.h.

◆ TALIGN

template<typename T>
typedef T aligned_value_type CRMatrix< T >::TALIGN(MIN_ALIGN2)

Definition at line 81 of file crmatrix.h.

◆ value_type

template<typename T>
typedef T CRMatrix< T >::value_type

Definition at line 79 of file crmatrix.h.

Constructor & Destructor Documentation

◆ CRMatrix() [1/4]

◆ CRMatrix() [2/4]

template<typename T>
CRMatrix< T >::CRMatrix ( unsigned int rows,
unsigned int columns )
inline

Definition at line 84 of file crmatrix.h.

References allocate(), columns(), and rows().

◆ CRMatrix() [3/4]

template<typename T>
CRMatrix< T >::CRMatrix ( const CRMatrix< T > & m)
inline

Definition at line 85 of file crmatrix.h.

References copy(), and CRMatrix().

◆ CRMatrix() [4/4]

template<typename T>
CRMatrix< T >::CRMatrix ( const Matrix< T > & mat)

Definition at line 171 of file crmatrix.h.

References allocate(), i, n_cols, n_rows, and T.

◆ ~CRMatrix()

template<typename T>
CRMatrix< T >::~CRMatrix ( )
inline

Definition at line 87 of file crmatrix.h.

References destroy().

Member Function Documentation

◆ allocate()

template<typename T>
void CRMatrix< T >::allocate ( unsigned int rows,
unsigned int columns )
protected

Definition at line 647 of file crmatrix.h.

References BCHKNR, colIndex, columns(), comp, dummy, i, n_cols, n_rows, NULL, rows(), rowSize, and T.

Referenced by CRMatrix(), CRMatrix(), CRMatrix(), and resize().

◆ clear()

template<typename T>
CRMatrix< T > & CRMatrix< T >::clear ( )
inline

set all elements defined to zero

Definition at line 725 of file crmatrix.h.

References CRMatrix(), fill(), and T.

Referenced by setunit().

◆ columns()

template<typename T>
unsigned int CRMatrix< T >::columns ( ) const
inline

Definition at line 119 of file crmatrix.h.

References n_cols.

Referenced by allocate(), CRMatrix(), operator<<(), and transposed_copy().

◆ copy()

template<typename T>
void CRMatrix< T >::copy ( const CRMatrix< T > & m)
protected

Definition at line 686 of file crmatrix.h.

References BCHKNR, colIndex, comp, CRMatrix(), dummy, i, n_cols, n_rows, NULL, rowSize, and T.

Referenced by CRMatrix(), and operator=().

◆ destroy()

template<typename T>
void CRMatrix< T >::destroy ( )
protected

◆ fill()

template<typename T>
CRMatrix< T > & CRMatrix< T >::fill ( const T & val)
inline

set all defined element to a val

Definition at line 716 of file crmatrix.h.

References comp, CRMatrix(), i, n_rows, rowSize, and T.

Referenced by clear().

◆ get()

template<typename T>
const T & CRMatrix< T >::get ( unsigned int row,
unsigned int column ) const
inline

Definition at line 101 of file crmatrix.h.

References T.

◆ get_row()

template<typename T>
TVector< T > CRMatrix< T >::get_row ( unsigned int row) const

Definition at line 312 of file crmatrix.h.

References BCHK, index, n_cols, n_rows, and TVector< T >::set().

◆ mat_info()

template<typename T>
const char * CRMatrix< T >::mat_info ( )
inlinestatic

Definition at line 90 of file crmatrix.h.

◆ MatVecMult() [1/2]

template<typename T>
void CRMatrix< T >::MatVecMult ( T * v,
T * res )

Definition at line 536 of file crmatrix.h.

References i, res, and T.

◆ MatVecMult() [2/2]

template<typename T>
void CRMatrix< T >::MatVecMult ( Vector< T > & res,
const Vector< T > & v ) const

Definition at line 519 of file crmatrix.h.

References BCHKNR, colIndex, comp, i, n_cols, n_rows, res, rowSize, TVector< T >::size(), and T.

Referenced by MatVecMult().

◆ mult()

template<typename T>
CRMatrix< T > CRMatrix< T >::mult ( const T & z) const

Definition at line 597 of file crmatrix.h.

References comp, CRMatrix(), i, n_rows, res, rowSize, and T.

Referenced by operator*().

◆ operator!=()

template<typename T>
bool CRMatrix< T >::operator!= ( const CRMatrix< T > & m) const
inline

Definition at line 128 of file crmatrix.h.

References CRMatrix(), and operator==().

◆ operator()() [1/2]

template<typename T>
T & CRMatrix< T >::operator() ( unsigned int row,
unsigned int column )
inline

Definition at line 106 of file crmatrix.h.

References setval(), and T.

◆ operator()() [2/2]

template<typename T>
const T & CRMatrix< T >::operator() ( unsigned int row,
unsigned int column ) const
inline

element access (read)

Definition at line 181 of file crmatrix.h.

References BCHK, colIndex, comp, dummy, index, n_cols, n_rows, rowSize, and T.

◆ operator*() [1/4]

template<typename T>
CRMatrix< T > CRMatrix< T >::operator* ( const T & z) const

Definition at line 585 of file crmatrix.h.

References CRMatrix(), i, res, and T.

◆ operator*() [2/4]

template<typename T>
TVector< T > CRMatrix< T >::operator* ( const TVector< T > & tv) const
inline

Definition at line 494 of file crmatrix.h.

◆ operator*() [3/4]

template<typename T>
TVector< T > CRMatrix< T >::operator* ( const Vector< T > & v) const

Definition at line 479 of file crmatrix.h.

References BCHK, colIndex, comp, i, n_cols, n_rows, res, rowSize, TVector< T >::size(), and T.

◆ operator*() [4/4]

template<typename T>
TVector< T > CRMatrix< T >::operator* ( TSVector< T > & tsv) const
inline

◆ operator*=()

template<typename T>
CRMatrix< T > & CRMatrix< T >::operator*= ( const T & z)

Definition at line 614 of file crmatrix.h.

References comp, CRMatrix(), i, n_rows, rowSize, and T.

◆ operator-()

template<typename T>
CRMatrix< T > CRMatrix< T >::operator- ( ) const

Definition at line 466 of file crmatrix.h.

References CRMatrix(), i, n_cols, n_rows, res, and T.

◆ operator/()

template<typename T>
CRMatrix< T > CRMatrix< T >::operator/ ( const T & z) const

Definition at line 624 of file crmatrix.h.

References CRMatrix(), i, n_rows, res, and T.

◆ operator/=()

template<typename T>
CRMatrix< T > & CRMatrix< T >::operator/= ( const T & z)

Definition at line 636 of file crmatrix.h.

References comp, CRMatrix(), i, n_rows, rowSize, and T.

◆ operator=()

template<typename T>
CRMatrix< T > & CRMatrix< T >::operator= ( const CRMatrix< T > & m)

Definition at line 409 of file crmatrix.h.

References BCHK, colIndex, comp, copy(), CRMatrix(), destroy(), i, n_rows, NULL, rowSize, and T.

◆ operator==()

template<typename T>
bool CRMatrix< T >::operator== ( const CRMatrix< T > & m) const

Definition at line 452 of file crmatrix.h.

References CRMatrix(), i, n_cols, and n_rows.

Referenced by operator!=().

◆ resize()

template<typename T>
void CRMatrix< T >::resize ( unsigned int newRows,
unsigned int newColumns )
inline

Definition at line 205 of file crmatrix.h.

References allocate(), destroy(), n_cols, and n_rows.

◆ rows()

template<typename T>
unsigned int CRMatrix< T >::rows ( ) const
inline

Definition at line 118 of file crmatrix.h.

References n_rows.

Referenced by allocate(), CRMatrix(), operator<<(), and transposed_copy().

◆ set_row() [1/4]

template<typename T>
void CRMatrix< T >::set_row ( const TSVector< T > & tsv,
unsigned int row )

Definition at line 368 of file crmatrix.h.

References set_row().

◆ set_row() [2/4]

template<typename T>
void CRMatrix< T >::set_row ( const TVector< T > & tv,
unsigned int row )

Definition at line 361 of file crmatrix.h.

References set_row().

◆ set_row() [3/4]

template<typename T>
void CRMatrix< T >::set_row ( const Vector< T > & v,
unsigned int row )

Definition at line 323 of file crmatrix.h.

References BCHKNR, colIndex, comp, index, n_rows, NULL, rowSize, TVector< T >::size(), and T.

Referenced by set_row(), and set_row().

◆ set_row() [4/4]

template<typename T>
void CRMatrix< T >::set_row ( T * value,
unsigned int row,
unsigned int count,
unsigned int * index )

Definition at line 377 of file crmatrix.h.

References BCHKNR, colIndex, comp, index, n_cols, n_rows, NULL, rowSize, and T.

◆ setunit()

template<typename T>
CRMatrix< T > & CRMatrix< T >::setunit ( const T & val = (T)1)
inline

set CSCMatrix to val times the unit matrix

Definition at line 729 of file crmatrix.h.

References BCHK, clear(), CRMatrix(), i, n_cols, n_rows, setunit(), setval(), and T.

Referenced by setunit().

◆ setval() [1/2]

template<typename T>
CRMatrix< T > & CRMatrix< T >::setval ( const T & z,
unsigned int row,
unsigned int column )

element access (write)

Definition at line 215 of file crmatrix.h.

References BCHK, colIndex, comp, CRMatrix(), i, index, n_cols, n_rows, NULL, rowSize, and T.

Referenced by operator()(), and setunit().

◆ setval() [2/2]

template<typename T>
T & CRMatrix< T >::setval ( unsigned int row,
unsigned int column )

Definition at line 261 of file crmatrix.h.

References BCHK, colIndex, comp, i, n_cols, n_rows, NULL, rowSize, and T.

◆ size()

template<typename T>
unsigned int CRMatrix< T >::size ( ) const

Definition at line 193 of file crmatrix.h.

References i, n_rows, and rowSize.

Referenced by TSVector< T >::add_t_tsv(), and TSVector< T >::sub_t_tsv().

◆ swap()

template<typename T>
CRMatrix< T > & CRMatrix< T >::swap ( CRMatrix< T > & m)

Definition at line 739 of file crmatrix.h.

References colIndex, comp, CRMatrix(), n_cols, n_rows, and rowSize.

Referenced by transpose().

◆ transMult() [1/3]

template<typename T>
TVector< T > CRMatrix< T >::transMult ( const TSVector< T > & tsv) const

Definition at line 576 of file crmatrix.h.

References transMult().

◆ transMult() [2/3]

template<typename T>
TVector< T > CRMatrix< T >::transMult ( const TVector< T > & tv) const

Definition at line 568 of file crmatrix.h.

References transMult().

◆ transMult() [3/3]

template<typename T>
TVector< T > CRMatrix< T >::transMult ( const Vector< T > & v) const

Definition at line 550 of file crmatrix.h.

References BCHK, colIndex, comp, i, n_cols, n_rows, res, rowSize, and TVector< T >::size().

Referenced by transMult(), and transMult().

◆ transpose()

template<typename T>
CRMatrix< T > & CRMatrix< T >::transpose ( )
inline

Definition at line 758 of file crmatrix.h.

References CRMatrix(), swap(), and transposed_copy().

◆ transposed_copy()

template<typename T>
CRMatrix< T > CRMatrix< T >::transposed_copy ( ) const

Inefficient! Use transMult if possible.

Definition at line 748 of file crmatrix.h.

References c, columns(), CRMatrix(), and rows().

Referenced by transpose(), and transpose().

◆ operator<<FGD

template<typename T>
STD__ ostream & operator<<FGD ( STD__ ostream & stream,
const CRMatrix< T > & m )
friend

References CRMatrix(), and STD__.

Member Data Documentation

◆ colIndex

template<typename T>
unsigned int** CRMatrix< T >::colIndex
protected

◆ comp

template<typename T>
T** CRMatrix< T >::comp
protected

◆ dummy

template<typename T>
T CRMatrix< T >::dummy
mutableprotected

Definition at line 70 of file crmatrix.h.

Referenced by allocate(), copy(), and operator()().

◆ n_cols

template<typename T>
unsigned int CRMatrix< T >::n_cols
protected

◆ n_rows

◆ rowSize

template<typename T>
unsigned int* CRMatrix< T >::rowSize
protected

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