Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
gnsstk::SparseMatrix< T > Class Template Reference

Detailed Description

template<class T>
class gnsstk::SparseMatrix< T >

Class SparseMatrix. This class is designed to present an interface nearly identical to class Matrix, but more efficiently handle sparse matrices, in which most of the elements are zero. The class stores only non-zero elements; using a map of SparseVectors, with key = row index. it also stores a nominal dimension - number of rows and columns. The class uses a proxy class, SMatProxy, to access elements; this allows rvalues and lvalues to be treated separately. Notes on speed. The most expensive parts are the Proxy::operator(), then find() and lower_bound(). Never use the Proxy stuff within the class, always use iterators and assign values to the maps directly. Never assign zeros to the maps. See timing and test results in the test program smtest.cpp Matrix multiply is orders of magnitude faster. Transpose() is much faster than the Matrix version, which is something of a surprise. Most time consuming is looping over columns; this is expected since the design stores by row. The trick is to re-write the algorithm in terms of the transpose of the column-loop matrix, and then apply a transpose(), which is cheap, either before starting (when col-loop matrix is input) or after returning (output). Then the loops become loops over rows. NB. never store zeros in the map, particularly when you are creating the matrix and using it at the same time, as in inverseLT().

Definition at line 53 of file SparseMatrix.hpp.

#include <SparseMatrix.hpp>

Public Member Functions

void clear ()
 clear - set all data to 0 (i.e. remove all data); leave dimensions alone More...
 
SparseVector< T > colCopy (const unsigned int j) const
 return col j of this SparseMatrix as a SparseVector More...
 
unsigned int cols () const
 get number of columns - of the real Matrix, not the data array More...
 
unsigned int datasize () const
 datasize - number of non-zero data More...
 
double density () const
 density - ratio of number of non-zero element to size() More...
 
SparseVector< T > diagCopy () const
 return diagonal of this SparseMatrix as a SparseVector More...
 
std::string dump (const int p=3, bool dosci=false) const
 Dump only non-zero values, with indexes (i,value) More...
 
void flatten (std::vector< unsigned int > &rows, std::vector< unsigned int > &cols, std::vector< T > &values) const
 Convert to "dump-able" form : 3 parallel vectors; rows, cols, values. More...
 
bool isEmpty () const
 is this SM empty? NB may have to call zeroize() to get a yes. More...
 
bool isFilled (const unsigned int i, const unsigned int j)
 true if the element (i,j) is non-zero More...
 
 operator Matrix< T > () const
 cast to Matrix or implicit conversion to Matrix<T> More...
 
SMatProxy< T > operator() (unsigned int i, unsigned int j)
 operator() for non-const, but SMatProxy does all the work More...
 
const SMatProxy< T > operator() (unsigned int i, unsigned int j) const
 operator() for const, but SMatProxy does all the work More...
 
SparseMatrix< T > & operator*= (const T &value)
 Multiply all elements by a scalar T constant. More...
 
SparseMatrix< T > & operator+= (const Matrix< T > &SM)
 Matrix addition: SparseMatrix += Matrix. More...
 
SparseMatrix< T > & operator+= (const SparseMatrix< T > &SM)
 Matrix addition: SparseMatrix += SparseMatrix. More...
 
SparseMatrix< T > operator- () const
 
SparseMatrix< T > & operator-= (const Matrix< T > &SM)
 Matrix subtraction: SparseMatrix -= Matrix. More...
 
SparseMatrix< T > & operator-= (const SparseMatrix< T > &SM)
 Minimum element - return 0 if empty. More...
 
SparseMatrix< T > & operator/= (const T &value)
 
void resize (const unsigned int newrows, const unsigned int newcols)
 resize - only changes len and removes elements if necessary More...
 
SparseVector< T > rowCopy (const unsigned int i) const
 return row i of this SparseMatrix as a SparseVector More...
 
unsigned int rows () const
 get number of rows - of the real Matrix, not the data array More...
 
unsigned int size () const
 size of matrix = rows()*cols() More...
 
 SparseMatrix ()
 empty constructor More...
 
 SparseMatrix (const Matrix< T > &M)
 constructor from regular Matrix<T> More...
 
 SparseMatrix (const SparseMatrix< T > &SM, const unsigned int &rind, const unsigned int &cind, const unsigned int &rnum, const unsigned int &cnum)
 
 SparseMatrix (unsigned int r, unsigned int c)
 constructor with dimensions More...
 
void swapCols (const unsigned int ii, const unsigned int jj)
 swap columns of this SparseMatrix More...
 
void swapRows (const unsigned int &ii, const unsigned int &jj)
 swap rows of this SparseMatrix More...
 
void zeroize (const T tol=static_cast< T >(SparseVector< T >::zeroTolerance))
 zeroize - remove elements that are less than tolerance in abs value More...
 

Private Member Functions

std::map< unsigned int, std::vector< unsigned int > > columnMap () const
 

Private Attributes

unsigned int ncols
 
unsigned int nrows
 dimensions of the "real" matrix (not the number of data stored) More...
 
std::map< unsigned int, SparseVector< T > > rowsMap
 map of row index, row SparseVector More...
 

Friends

SparseMatrix< T > identSparse (const unsigned int dim)
 
SparseMatrix< T > inverse (const SparseMatrix< T > &A)
 
SparseMatrix< T > inverseLT (const SparseMatrix< T > &LT, T *ptrSmall, T *ptrBig)
 Compute inverse of lower-triangular SparseMatrix. More...
 
SparseMatrix< T > inverseViaCholesky (const SparseMatrix< T > &A)
 
SparseMatrix< T > lowerCholesky (const SparseMatrix< T > &A)
 
SparseMatrix< T > matrixTimesTranspose (const SparseMatrix< T > &M)
 
max (const SparseMatrix< T > &SM)
 Maximum element - return 0 if empty. More...
 
maxabs (const SparseMatrix< T > &SM)
 Maximum absolute value - return 0 if empty. More...
 
min (const SparseMatrix< T > &SM)
 Maximum element - return 0 if empty. More...
 
minabs (const SparseMatrix< T > &SM)
 Minimum absolute value - return 0 if empty. More...
 
std::ostream & operator (std::ostream &os, const SparseMatrix< T > &S)
 
SparseMatrix< T > operator* (const Matrix< T > &L, const SparseMatrix< T > &R)
 Matrix multiply: SparseMatrix = Matrix * SparseMatrix. More...
 
SparseVector< T > operator* (const Matrix< T > &L, const SparseVector< T > &V)
 Matrix,Vector multiply: SparseVector = Matrix * SparseVector. More...
 
SparseMatrix< T > operator* (const SparseMatrix< T > &L, const Matrix< T > &R)
 Matrix multiply: SparseMatrix = SparseMatrix * Matrix. More...
 
SparseMatrix< T > operator* (const SparseMatrix< T > &L, const SparseMatrix< T > &R)
 Matrix multiply: SparseMatrix = SparseMatrix * SparseMatrix. More...
 
SparseMatrix< T > operator* (const SparseMatrix< T > &L, const SparseMatrix< T > &R)
 Matrix multiply: SparseMatrix = SparseMatrix * SparseMatrix. More...
 
SparseVector< T > operator* (const SparseMatrix< T > &L, const SparseVector< T > &V)
 Matrix,Vector multiply: SparseVector = SparseMatrix * SparseVector. More...
 
SparseVector< T > operator* (const SparseMatrix< T > &L, const Vector< T > &V)
 Matrix,Vector multiply: SparseVector = SparseMatrix * Vector. More...
 
SparseVector< T > operator* (const SparseVector< T > &V, const Matrix< T > &R)
 Vector,Matrix multiply: SparseVector = SparseVector * Matrix. More...
 
SparseVector< T > operator* (const SparseVector< T > &V, const SparseMatrix< T > &R)
 Vector,Matrix multiply: SparseVector = SparseVector * SparseMatrix. More...
 
SparseVector< T > operator* (const Vector< T > &V, const SparseMatrix< T > &R)
 Vector,Matrix multiply: SparseVector = Vector * SparseMatrix. More...
 
SparseMatrix< T > operator+ (const Matrix< T > &L, const SparseMatrix< T > &R)
 
SparseMatrix< T > operator+ (const SparseMatrix< T > &L, const Matrix< T > &R)
 Matrix addition: SparseMatrix = SparseMatrix + Matrix : copy, += M. More...
 
SparseMatrix< T > operator+ (const SparseMatrix< T > &L, const SparseMatrix< T > &R)
 Matrix addition: SparseMatrix = SparseMatrix + SparseMatrix : copy, += SM. More...
 
SparseMatrix< T > operator- (const Matrix< T > &L, const SparseMatrix< T > &R)
 Matrix subtraction: SparseMatrix = Matrix - SparseMatrix. More...
 
SparseMatrix< T > operator- (const SparseMatrix< T > &L, const Matrix< T > &R)
 Matrix subtraction: SparseMatrix = SparseMatrix - Matrix. More...
 
SparseMatrix< T > operator- (const SparseMatrix< T > &L, const SparseMatrix< T > &R)
 Matrix subtraction: SparseMatrix = SparseMatrix - SparseMatrix. More...
 
SparseMatrix< T > operator|| (const SparseMatrix< T > &L, const SparseMatrix< T > &R)
 
SparseMatrix< T > operator|| (const SparseMatrix< T > &L, const Vector< T > &V)
 Concatenation SparseMatrix || Vector TD the rest of them... More...
 
class SMatProxy< T >
 Proxy needs access to rowsMap. More...
 
SparseMatrix< T > SparseHouseholder (const SparseMatrix< T > &A)
 Householder transformation of a matrix. More...
 
void SrifMU (Matrix< T > &R, Vector< T > &Z, SparseMatrix< T > &A, const unsigned int M)
 
void SrifMU (Matrix< T > &R, Vector< T > &Z, SparseMatrix< T > &P, Vector< T > &D, const unsigned int M)
 
Vector< T > transformDiag (const SparseMatrix< T > &P, const Matrix< T > &C)
 Compute diagonal of P*C*P^T, ie diagonal of transform of square Matrix C. More...
 
SparseMatrix< T > transpose (const SparseMatrix< T > &M)
 transpose More...
 
SparseMatrix< T > transposeTimesMatrix (const SparseMatrix< T > &M)
 
SparseMatrix< T > upperCholesky (const SparseMatrix< T > &A)
 

Constructor & Destructor Documentation

◆ SparseMatrix() [1/4]

template<class T >
gnsstk::SparseMatrix< T >::SparseMatrix ( )
inline

empty constructor

Definition at line 436 of file SparseMatrix.hpp.

◆ SparseMatrix() [2/4]

template<class T >
gnsstk::SparseMatrix< T >::SparseMatrix ( unsigned int  r,
unsigned int  c 
)
inline

constructor with dimensions

Definition at line 439 of file SparseMatrix.hpp.

◆ SparseMatrix() [3/4]

template<class T >
gnsstk::SparseMatrix< T >::SparseMatrix ( const SparseMatrix< T > &  SM,
const unsigned int &  rind,
const unsigned int &  cind,
const unsigned int &  rnum,
const unsigned int &  cnum 
)

sub-matrix constructor

Parameters
SVSparseVector to copy
indstarting index for the copy
nlength of new SparseVector

Definition at line 726 of file SparseMatrix.hpp.

◆ SparseMatrix() [4/4]

template<class T >
gnsstk::SparseMatrix< T >::SparseMatrix ( const Matrix< T > &  M)

constructor from regular Matrix<T>

Definition at line 760 of file SparseMatrix.hpp.

Member Function Documentation

◆ clear()

template<class T >
void gnsstk::SparseMatrix< T >::clear ( )
inline

clear - set all data to 0 (i.e. remove all data); leave dimensions alone

Definition at line 514 of file SparseMatrix.hpp.

◆ colCopy()

template<class T >
SparseVector< T > gnsstk::SparseMatrix< T >::colCopy ( const unsigned int  j) const

return col j of this SparseMatrix as a SparseVector

Definition at line 1676 of file SparseMatrix.hpp.

◆ cols()

template<class T >
unsigned int gnsstk::SparseMatrix< T >::cols ( ) const
inline

get number of columns - of the real Matrix, not the data array

Definition at line 463 of file SparseMatrix.hpp.

◆ columnMap()

template<class T >
std::map<unsigned int, std::vector<unsigned int> > gnsstk::SparseMatrix< T >::columnMap ( ) const
inlineprivate

private function to build a "column map" for this matrix, containing vectors (of row-indexes) for each column. colMap[column index] = vector of all row indexes, in ascending order

Definition at line 676 of file SparseMatrix.hpp.

◆ datasize()

template<class T >
unsigned int gnsstk::SparseMatrix< T >::datasize ( ) const
inline

datasize - number of non-zero data

Definition at line 469 of file SparseMatrix.hpp.

◆ density()

template<class T >
double gnsstk::SparseMatrix< T >::density ( ) const
inline

density - ratio of number of non-zero element to size()

Definition at line 486 of file SparseMatrix.hpp.

◆ diagCopy()

template<class T >
SparseVector< T > gnsstk::SparseMatrix< T >::diagCopy

return diagonal of this SparseMatrix as a SparseVector

Definition at line 1694 of file SparseMatrix.hpp.

◆ dump()

template<class T >
std::string gnsstk::SparseMatrix< T >::dump ( const int  p = 3,
bool  dosci = false 
) const
inline

Dump only non-zero values, with indexes (i,value)

Definition at line 570 of file SparseMatrix.hpp.

◆ flatten()

template<class T >
void gnsstk::SparseMatrix< T >::flatten ( std::vector< unsigned int > &  rows,
std::vector< unsigned int > &  cols,
std::vector< T > &  values 
) const
inline

Convert to "dump-able" form : 3 parallel vectors; rows, cols, values.

Definition at line 596 of file SparseMatrix.hpp.

◆ isEmpty()

template<class T >
bool gnsstk::SparseMatrix< T >::isEmpty ( ) const
inline

is this SM empty? NB may have to call zeroize() to get a yes.

Definition at line 480 of file SparseMatrix.hpp.

◆ isFilled()

template<class T >
bool gnsstk::SparseMatrix< T >::isFilled ( const unsigned int  i,
const unsigned int  j 
)
inline

true if the element (i,j) is non-zero

Definition at line 528 of file SparseMatrix.hpp.

◆ operator Matrix< T >()

template<class T >
gnsstk::SparseMatrix< T >::operator Matrix< T >

cast to Matrix or implicit conversion to Matrix<T>

cast to Matrix<T>

Definition at line 788 of file SparseMatrix.hpp.

◆ operator()() [1/2]

template<class T >
SMatProxy<T> gnsstk::SparseMatrix< T >::operator() ( unsigned int  i,
unsigned int  j 
)
inline

operator() for non-const, but SMatProxy does all the work

Definition at line 553 of file SparseMatrix.hpp.

◆ operator()() [2/2]

template<class T >
const SMatProxy<T> gnsstk::SparseMatrix< T >::operator() ( unsigned int  i,
unsigned int  j 
) const
inline

operator() for const, but SMatProxy does all the work

Definition at line 537 of file SparseMatrix.hpp.

◆ operator*=()

template<class T >
SparseMatrix< T > & gnsstk::SparseMatrix< T >::operator*= ( const T &  value)

Multiply all elements by a scalar T constant.

Definition at line 1560 of file SparseMatrix.hpp.

◆ operator+=() [1/2]

template<class T >
SparseMatrix< T > & gnsstk::SparseMatrix< T >::operator+= ( const Matrix< T > &  SM)

Matrix addition: SparseMatrix += Matrix.

Definition at line 1530 of file SparseMatrix.hpp.

◆ operator+=() [2/2]

template<class T >
SparseMatrix< T > & gnsstk::SparseMatrix< T >::operator+= ( const SparseMatrix< T > &  SM)

Matrix addition: SparseMatrix += SparseMatrix.

Definition at line 1501 of file SparseMatrix.hpp.

◆ operator-()

template<class T >
SparseMatrix<T> gnsstk::SparseMatrix< T >::operator- ( ) const
inline

Definition at line 633 of file SparseMatrix.hpp.

◆ operator-=() [1/2]

template<class T >
SparseMatrix< T > & gnsstk::SparseMatrix< T >::operator-= ( const Matrix< T > &  SM)

Matrix subtraction: SparseMatrix -= Matrix.

Definition at line 1422 of file SparseMatrix.hpp.

◆ operator-=() [2/2]

template<class T >
SparseMatrix< T > & gnsstk::SparseMatrix< T >::operator-= ( const SparseMatrix< T > &  SM)

Minimum element - return 0 if empty.

Matrix subtraction: SparseMatrix -= SparseMatrix.

Definition at line 1393 of file SparseMatrix.hpp.

◆ operator/=()

template<class T >
SparseMatrix< T > & gnsstk::SparseMatrix< T >::operator/= ( const T &  value)
Exceptions
ExceptionDivide all elements by a scalar T constant
Exceptionif the constant is zero

Definition at line 1586 of file SparseMatrix.hpp.

◆ resize()

template<class T >
void gnsstk::SparseMatrix< T >::resize ( const unsigned int  newrows,
const unsigned int  newcols 
)
inline

resize - only changes len and removes elements if necessary

Definition at line 492 of file SparseMatrix.hpp.

◆ rowCopy()

template<class T >
SparseVector< T > gnsstk::SparseMatrix< T >::rowCopy ( const unsigned int  i) const

return row i of this SparseMatrix as a SparseVector

Definition at line 1662 of file SparseMatrix.hpp.

◆ rows()

template<class T >
unsigned int gnsstk::SparseMatrix< T >::rows ( ) const
inline

get number of rows - of the real Matrix, not the data array

Definition at line 460 of file SparseMatrix.hpp.

◆ size()

template<class T >
unsigned int gnsstk::SparseMatrix< T >::size ( ) const
inline

size of matrix = rows()*cols()

Definition at line 466 of file SparseMatrix.hpp.

◆ swapCols()

template<class T >
void gnsstk::SparseMatrix< T >::swapCols ( const unsigned int  ii,
const unsigned int  jj 
)

swap columns of this SparseMatrix

Definition at line 1754 of file SparseMatrix.hpp.

◆ swapRows()

template<class T >
void gnsstk::SparseMatrix< T >::swapRows ( const unsigned int &  ii,
const unsigned int &  jj 
)

swap rows of this SparseMatrix

Definition at line 1713 of file SparseMatrix.hpp.

◆ zeroize()

template<class T >
void gnsstk::SparseMatrix< T >::zeroize ( const tol = static_cast<T>(SparseVector<T>::zeroTolerance))

zeroize - remove elements that are less than tolerance in abs value

zeroize - remove elements that are less than tolerance in abs value NB. This routine is called only by the user - routines defined here do not zeroize, as there is no way to appropriately choose a tolerance. The default tolerance for this routine is SparseVector<T>::zeroTolerance. The caller may want to consider a tolerance related to SM.maxabs().

Definition at line 806 of file SparseMatrix.hpp.

Friends And Related Function Documentation

◆ identSparse

template<class T >
SparseMatrix<T> identSparse ( const unsigned int  dim)
friend

Compute the identity matrix of dimension dim x dim

Parameters
dimdimension of desired identity matrix (dim x dim)
Returns
identity matrix

Definition at line 1776 of file SparseMatrix.hpp.

◆ inverse

template<class T >
SparseMatrix<T> inverse ( const SparseMatrix< T > &  A)
friend

inverse (via Gauss-Jordan)

Exceptions
Exceptioninverse via Gauss-Jordan; NB GJ involves only row operations. NB not the best numerically; for high condition number, use inverseViaCholesky, or cast to Matrix, use either LUD or SVD, then cast back to SparseMatrix.
Exception

Definition at line 1890 of file SparseMatrix.hpp.

◆ inverseLT

template<class T >
SparseMatrix<T> inverseLT ( const SparseMatrix< T > &  LT,
T *  ptrSmall,
T *  ptrBig 
)
friend

Compute inverse of lower-triangular SparseMatrix.

inverseLT

Exceptions
Exception
Exception

Definition at line 2154 of file SparseMatrix.hpp.

◆ inverseViaCholesky

template<class T >
SparseMatrix<T> inverseViaCholesky ( const SparseMatrix< T > &  A)
friend
Exceptions
ExceptionCompute inverse of a symmetric positive definite matrix using Cholesky decomposition.
Parameters
ASparseMatrix to be inverted; symmetric and positive definite, const
Returns
SparseMatrix inverse of input matrix
Exceptions
Exceptionif input SparseMatrix is not square, not positive definite, or singular

Definition at line 2277 of file SparseMatrix.hpp.

◆ lowerCholesky

template<class T >
SparseMatrix<T> lowerCholesky ( const SparseMatrix< T > &  A)
friend

Cholesky

Exceptions
ExceptionCompute lower triangular square root of a symmetric positive definite matrix (Cholesky decomposition) Crout algorithm.
Parameters
ASparseMatrix to be decomposed; symmetric and positive definite, const
Returns
SparseMatrix lower triangular square root of input matrix
Exceptions
ifinput SparseMatrix is not square
ifinput SparseMatrix is not positive definite
Exception

Definition at line 2065 of file SparseMatrix.hpp.

◆ matrixTimesTranspose

template<class T >
SparseMatrix<T> matrixTimesTranspose ( const SparseMatrix< T > &  M)
friend

M * MT

Exceptions
Exception

Definition at line 1802 of file SparseMatrix.hpp.

◆ max

template<class T >
T max ( const SparseMatrix< T > &  SM)
friend

Maximum element - return 0 if empty.

Definition at line 881 of file SparseMatrix.hpp.

◆ maxabs

template<class T >
T maxabs ( const SparseMatrix< T > &  SM)
friend

Maximum absolute value - return 0 if empty.

Definition at line 927 of file SparseMatrix.hpp.

◆ min

template<class T >
T min ( const SparseMatrix< T > &  SM)
friend

Maximum element - return 0 if empty.

Definition at line 858 of file SparseMatrix.hpp.

◆ minabs

template<class T >
T minabs ( const SparseMatrix< T > &  SM)
friend

Minimum absolute value - return 0 if empty.

Definition at line 904 of file SparseMatrix.hpp.

◆ operator

template<class T >
std::ostream& operator ( std::ostream &  os,
const SparseMatrix< T > &  S 
)
friend

◆ operator* [1/10]

template<class T >
SparseMatrix<T> operator* ( const Matrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Matrix multiply: SparseMatrix = Matrix * SparseMatrix.

Definition at line 1270 of file SparseMatrix.hpp.

◆ operator* [2/10]

template<class T >
SparseVector<T> operator* ( const Matrix< T > &  L,
const SparseVector< T > &  V 
)
friend

Matrix,Vector multiply: SparseVector = Matrix * SparseVector.

Definition at line 1023 of file SparseMatrix.hpp.

◆ operator* [3/10]

template<class T >
SparseMatrix<T> operator* ( const SparseMatrix< T > &  L,
const Matrix< T > &  R 
)
friend

Matrix multiply: SparseMatrix = SparseMatrix * Matrix.

Definition at line 1225 of file SparseMatrix.hpp.

◆ operator* [4/10]

template<class T >
SparseMatrix<T> operator* ( const SparseMatrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Matrix multiply: SparseMatrix = SparseMatrix * SparseMatrix.

Definition at line 1186 of file SparseMatrix.hpp.

◆ operator* [5/10]

template<class T >
SparseMatrix<T> operator* ( const SparseMatrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Matrix multiply: SparseMatrix = SparseMatrix * SparseMatrix.

Definition at line 1186 of file SparseMatrix.hpp.

◆ operator* [6/10]

template<class T >
SparseVector<T> operator* ( const SparseMatrix< T > &  L,
const SparseVector< T > &  V 
)
friend

Matrix,Vector multiply: SparseVector = SparseMatrix * SparseVector.

Definition at line 996 of file SparseMatrix.hpp.

◆ operator* [7/10]

template<class T >
SparseVector<T> operator* ( const SparseMatrix< T > &  L,
const Vector< T > &  V 
)
friend

Matrix,Vector multiply: SparseVector = SparseMatrix * Vector.

Definition at line 1056 of file SparseMatrix.hpp.

◆ operator* [8/10]

template<class T >
SparseVector<T> operator* ( const SparseVector< T > &  V,
const Matrix< T > &  R 
)
friend

Vector,Matrix multiply: SparseVector = SparseVector * Matrix.

Definition at line 1119 of file SparseMatrix.hpp.

◆ operator* [9/10]

template<class T >
SparseVector<T> operator* ( const SparseVector< T > &  V,
const SparseMatrix< T > &  R 
)
friend

Vector,Matrix multiply: SparseVector = SparseVector * SparseMatrix.

Definition at line 1083 of file SparseMatrix.hpp.

◆ operator* [10/10]

template<class T >
SparseVector<T> operator* ( const Vector< T > &  V,
const SparseMatrix< T > &  R 
)
friend

Vector,Matrix multiply: SparseVector = Vector * SparseMatrix.

Definition at line 1153 of file SparseMatrix.hpp.

◆ operator+ [1/3]

template<class T >
SparseMatrix<T> operator+ ( const Matrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Matrix addition: SparseMatrix = Matrix + SparseMatrix : copy, += M in rev order

Definition at line 1643 of file SparseMatrix.hpp.

◆ operator+ [2/3]

template<class T >
SparseMatrix<T> operator+ ( const SparseMatrix< T > &  L,
const Matrix< T > &  R 
)
friend

Matrix addition: SparseMatrix = SparseMatrix + Matrix : copy, += M.

Definition at line 1624 of file SparseMatrix.hpp.

◆ operator+ [3/3]

template<class T >
SparseMatrix<T> operator+ ( const SparseMatrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Matrix addition: SparseMatrix = SparseMatrix + SparseMatrix : copy, += SM.

Definition at line 1608 of file SparseMatrix.hpp.

◆ operator- [1/3]

template<class T >
SparseMatrix<T> operator- ( const Matrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Matrix subtraction: SparseMatrix = Matrix - SparseMatrix.

Definition at line 1483 of file SparseMatrix.hpp.

◆ operator- [2/3]

template<class T >
SparseMatrix<T> operator- ( const SparseMatrix< T > &  L,
const Matrix< T > &  R 
)
friend

Matrix subtraction: SparseMatrix = SparseMatrix - Matrix.

Definition at line 1467 of file SparseMatrix.hpp.

◆ operator- [3/3]

template<class T >
SparseMatrix<T> operator- ( const SparseMatrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Matrix subtraction: SparseMatrix = SparseMatrix - SparseMatrix.

Definition at line 1451 of file SparseMatrix.hpp.

◆ operator|| [1/2]

template<class T >
SparseMatrix<T> operator|| ( const SparseMatrix< T > &  L,
const SparseMatrix< T > &  R 
)
friend

Definition at line 1343 of file SparseMatrix.hpp.

◆ operator|| [2/2]

template<class T >
SparseMatrix<T> operator|| ( const SparseMatrix< T > &  L,
const Vector< T > &  V 
)
friend

Concatenation SparseMatrix || Vector TD the rest of them...

Definition at line 1313 of file SparseMatrix.hpp.

◆ SMatProxy< T >

template<class T >
friend class SMatProxy< T >
friend

Proxy needs access to rowsMap.

Definition at line 361 of file SparseMatrix.hpp.

◆ SparseHouseholder

template<class T >
SparseMatrix<T> SparseHouseholder ( const SparseMatrix< T > &  A)
friend

Householder transformation of a matrix.

Householder

Exceptions
Exception

Definition at line 2297 of file SparseMatrix.hpp.

◆ SrifMU [1/2]

template<class T >
void SrifMU ( Matrix< T > &  R,
Vector< T > &  Z,
SparseMatrix< T > &  A,
const unsigned int  M 
)
friend
Exceptions
ExceptionSquare root information measurement update, with new data in the form of a single SparseMatrix concatenation of H and D: A = H || D. See doc for the overloaded SrifMU().

Definition at line 2467 of file SparseMatrix.hpp.

◆ SrifMU [2/2]

template<class T >
void SrifMU ( Matrix< T > &  R,
Vector< T > &  Z,
SparseMatrix< T > &  P,
Vector< T > &  D,
const unsigned int  M 
)
friend
Exceptions
Exception

Definition at line 2627 of file SparseMatrix.hpp.

◆ transformDiag

template<class T >
Vector<T> transformDiag ( const SparseMatrix< T > &  P,
const Matrix< T > &  C 
)
friend

Compute diagonal of P*C*P^T, ie diagonal of transform of square Matrix C.

diag of P * C * PT

Exceptions
Exception

Definition at line 1836 of file SparseMatrix.hpp.

◆ transpose

template<class T >
SparseMatrix<T> transpose ( const SparseMatrix< T > &  M)
friend

transpose

Definition at line 829 of file SparseMatrix.hpp.

◆ transposeTimesMatrix

template<class T >
SparseMatrix<T> transposeTimesMatrix ( const SparseMatrix< T > &  M)
friend

products MT*M, M*MT, M*C*MT etc MT * M

Exceptions
Exception

◆ upperCholesky

template<class T >
SparseMatrix<T> upperCholesky ( const SparseMatrix< T > &  A)
friend
Exceptions
ExceptionCompute upper triangular square root of a symmetric positive definite matrix (Cholesky decomposition) Crout algorithm; that is A = transpose(U)*U. Note that this result will be equal to transpose(lowerCholesky(A)) == transpose(Ch.L from class Cholesky), NOT Ch.U; class Cholesky computes L,U where A = L*LT = U*UT [while A=UT*U here].
Parameters
ASparseMatrix to be decomposed; symmetric and positive definite, const
Returns
SparseMatrix upper triangular square root of input matrix
Exceptions
Exceptionif input SparseMatrix is not square
Exceptionif input SparseMatrix is not positive definite

Definition at line 2262 of file SparseMatrix.hpp.

Member Data Documentation

◆ ncols

template<class T >
unsigned int gnsstk::SparseMatrix< T >::ncols
private

Definition at line 664 of file SparseMatrix.hpp.

◆ nrows

template<class T >
unsigned int gnsstk::SparseMatrix< T >::nrows
private

dimensions of the "real" matrix (not the number of data stored)

Definition at line 664 of file SparseMatrix.hpp.

◆ rowsMap

template<class T >
std::map<unsigned int, SparseVector<T> > gnsstk::SparseMatrix< T >::rowsMap
private

map of row index, row SparseVector

Definition at line 667 of file SparseMatrix.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:46