Free Electron
Public Member Functions | Protected Member Functions | Protected Attributes | Related Functions | List of all members
fe::ext::SparseMatrix< T > Class Template Reference

Dense array of sparse rows. More...

#include <ListSparseMatrix.h>

Inheritance diagram for fe::ext::SparseMatrix< T >:
Inheritance graph
[legend]

Public Member Functions

 SparseMatrix (U32 rows, U32 columns)
 
 SparseMatrix (const SparseMatrix< T > &rhs)
 
SparseMatrix< T > & operator= (const SparseMatrix< T > &rhs)
 
operator() (U32 i, U32 j) const
 
T & operator() (U32 i, U32 j)
 
void reset (U32 rows, U32 columns)
 
void clear (void)
 
U32 rows (void) const
 
U32 columns (void) const
 
void setTranspose (const SparseMatrix< T > &rhs)
 
void setSum (const SparseMatrix< T > &rhs)
 
void setDifference (const SparseMatrix< T > &rhs)
 
void premultiplyDiagonal (const SparseMatrix< T > &diag, SparseMatrix< T > &b) const
 
void scale (const F32 scalar, SparseMatrix< T > &result) const
 
void transform (const DenseVector< T > &x, DenseVector< T > &b) const
 
void transposeTransform (const DenseVector< T > &x, DenseVector< T > &b) const
 
 SparseMatrix (U32 rows, U32 columns)
 
 SparseMatrix (const SparseMatrix< T, ROW > &rhs)
 
SparseMatrix< T, ROW > & operator= (const SparseMatrix< T, ROW > &rhs)
 
operator() (U32 i, U32 j) const
 
T & operator() (U32 i, U32 j)
 
void reset (U32 rows, U32 columns)
 
void clear (void)
 
U32 rows (void) const
 
U32 columns (void) const
 
void setTranspose (const SparseMatrix< T, ROW > &rhs)
 
void setSum (const SparseMatrix< T, ROW > &rhs)
 
void setDifference (const SparseMatrix< T, ROW > &rhs)
 
void setProduct (const SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 
void premultiplyDiagonal (const SparseMatrix< T, ROW > &diag, SparseMatrix< T, ROW > &b) const
 
void premultiplyDiagonal (const DenseVector< T > &diag, SparseMatrix< T, ROW > &b) const
 
void premultiplyInverseDiagonal (const SparseMatrix< T, ROW > &diag, SparseMatrix< T, ROW > &b) const
 
void premultiplyInverseDiagonal (const DenseVector< T > &diag, SparseMatrix< T, ROW > &b) const
 
void postmultiplyDiagonal (const DenseVector< T > &diag, SparseMatrix< T, ROW > &b) const
 
void postmultiplyInverseDiagonal (const SparseMatrix< T, ROW > &diag, SparseMatrix< T, ROW > &b) const
 
void postmultiplyInverseDiagonal (const DenseVector< T > &diag, SparseMatrix< T, ROW > &b) const
 
void scale (const F32 scalar)
 
void scale (const F32 scalar, SparseMatrix< T, ROW > &result) const
 
void transform (const DenseVector< T > &x, DenseVector< T > &b) const
 
void transposeTransform (const DenseVector< T > &x, DenseVector< T > &b) const
 

Protected Member Functions

BWORD seek (U32 i, U32 j) const
 

Protected Attributes

U32 m_rows
 
U32 m_columns
 
Row * m_pRow
 
Row * m_pCurrent
 
ListCore::Context m_context
 
ROW * m_pRow
 

Related Functions

(Note that these are not member functions.)

template<class T >
BWORD isSquare (const SparseMatrix< T > &matrix)
 Return true is matrix is square, otherwise return false. More...
 
template<class T >
SparseMatrix< T > & setIdentity (SparseMatrix< T > &matrix)
 Set matrix to identity matrix. More...
 
template<class T >
SparseMatrix< T > transpose (const SparseMatrix< T > &matrix)
 Return transpose of matrix. More...
 
template<class T >
SparseMatrix< T > operator+ (const SparseMatrix< T > &lhs, const SparseMatrix< T > &rhs)
 SparseMatrix add. More...
 
template<class T >
SparseMatrix< T > operator- (const SparseMatrix< T > &lhs, const SparseMatrix< T > &rhs)
 SparseMatrix subtract. More...
 
template<class T >
SparseMatrix< T > premultiplyDiagonal (const SparseMatrix< T > &lhs, const SparseMatrix< T > &rhs)
 SparseMatrix-SparseMatrix multiply where first matrix is a diagonal. More...
 
template<class T >
DenseVector< T > operator* (const SparseMatrix< T > &lhs, const DenseVector< T > &rhs)
 SparseMatrix-Vector multiply. More...
 
template<class T >
DenseVector< T > transposeMultiply (const SparseMatrix< T > &lhs, const DenseVector< T > &rhs)
 SparseMatrix-Vector multiply with matrix transposed. More...
 
template<class T >
SparseMatrix< T > operator* (const SparseMatrix< T > &matrix, const F32 scalar)
 SparseMatrix-Scalar post-multiply. More...
 
template<class T >
SparseMatrix< T > operator* (const F32 scalar, const SparseMatrix< T > &matrix)
 SparseMatrix-Scalar pre-multiply. More...
 
template<class T >
String print (const SparseMatrix< T > &matrix)
 SparseMatrix print. More...
 
template<class T , class ROW >
U32 width (const SparseMatrix< T, ROW > &matrix)
 Return the horizonatal dimension. More...
 
template<class T , class ROW >
U32 height (const SparseMatrix< T, ROW > &matrix)
 Return the vertical dimension. More...
 
template<class T , class ROW >
void premultiplyDiagonal (DenseVector< T > &result, const SparseMatrix< T, ROW > &diagonal, const DenseVector< T > &vector)
 Compute the per-element product of the vector and the diagonal entries. More...
 
template<class T , class ROW >
void premultiplyInverseDiagonal (DenseVector< T > &result, const SparseMatrix< T, ROW > &diagonal, const DenseVector< T > &vector)
 Compute the per-element product of the vector and the inverse diagonal entries. More...
 
template<class T , class ROW >
BWORD isSquare (const SparseMatrix< T, ROW > &matrix)
 Return true is matrix is square, otherwise return false. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & setIdentity (SparseMatrix< T, ROW > &matrix)
 Set matrix to identity matrix. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > transpose (const SparseMatrix< T, ROW > &matrix)
 Return transpose of matrix. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > operator+ (const SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix add. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > operator- (const SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix subtract. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & operator+= (SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix add in place. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & operator-= (SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix subtract in place. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyDiagonal (SparseMatrix< T, ROW > &result, const DenseVector< T > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix-SparseMatrix multiply where first matrix is presumed diagonal. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyDiagonal (SparseMatrix< T, ROW > &result, const SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix-SparseMatrix multiply where first matrix is presumed diagonal. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyInverseDiagonal (SparseMatrix< T, ROW > &result, const SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix-SparseMatrix multiply where first matrix is presumed diagonal. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyInverseDiagonal (SparseMatrix< T, ROW > &result, const DenseVector< T > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix-SparseMatrix multiply where first matrix is a diagonal represented with a vector. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & postmultiplyDiagonal (SparseMatrix< T, ROW > &result, const SparseMatrix< T, ROW > &lhs, const DenseVector< T > &rhs)
 SparseMatrix-SparseMatrix multiply where second matrix is a diagonal. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & postmultiplyInverseDiagonal (SparseMatrix< T, ROW > &result, const SparseMatrix< T, ROW > &lhs, const SparseMatrix< T, ROW > &rhs)
 SparseMatrix-SparseMatrix multiply where second matrix is presumed diagonal. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & postmultiplyInverseDiagonal (SparseMatrix< T, ROW > &result, const SparseMatrix< T, ROW > &lhs, const DenseVector< T > &rhs)
 SparseMatrix-SparseMatrix multiply where second matrix is a diagonal represented by a vector. More...
 
template<class T , class ROW >
DenseVector< T > operator* (const SparseMatrix< T, ROW > &lhs, const DenseVector< T > &rhs)
 SparseMatrix-Vector multiply. More...
 
template<class T , class ROW >
void transformVector (const SparseMatrix< T, ROW > &lhs, const DenseVector< T > &in, DenseVector< T > &out)
 SparseMatrix-Vector multiply with matrix. More...
 
template<class T , class ROW >
void transposeTransformVector (const SparseMatrix< T, ROW > &lhs, const DenseVector< T > &in, DenseVector< T > &out)
 SparseMatrix-Vector multiply with matrix transposed. More...
 
template<class T , class ROW , class U >
SparseMatrix< T, ROW > operator* (const SparseMatrix< T, ROW > &matrix, const U scalar)
 SparseMatrix-Scalar post-multiply. More...
 
template<class T , class ROW , class U >
SparseMatrix< T, ROW > operator* (const U scalar, const SparseMatrix< T, ROW > &matrix)
 SparseMatrix-Scalar pre-multiply. More...
 
template<class T , class ROW >
SparseMatrix< T, ROW > & operator*= (SparseMatrix< T, ROW > &lhs, const F32 scalar)
 SparseMatrix-Scalar multiply in place. More...
 

Detailed Description

template<class T>
class fe::ext::SparseMatrix< T >

Dense array of sparse rows.

SparseMatrix has some similar functionailty to Matrix through overloaded non-member operations.

Only a small number of operations are implemented for SparseMatrix. Others may be added as needed.

SparseMatrix has some similar functionality to Matrix through overloaded non-member operations.

Only a small number of operations are implemented for SparseMatrix. Others may be added as needed.

Friends And Related Function Documentation

◆ height()

template<class T , class ROW >
U32 height ( const SparseMatrix< T, ROW > &  matrix)
related

Return the vertical dimension.

◆ isSquare() [1/2]

template<class T >
BWORD isSquare ( const SparseMatrix< T > &  matrix)
related

Return true is matrix is square, otherwise return false.

◆ isSquare() [2/2]

template<class T , class ROW >
BWORD isSquare ( const SparseMatrix< T, ROW > &  matrix)
related

Return true is matrix is square, otherwise return false.

◆ operator*() [1/6]

template<class T >
DenseVector< T > operator* ( const SparseMatrix< T > &  lhs,
const DenseVector< T > &  rhs 
)
related

SparseMatrix-Vector multiply.

◆ operator*() [2/6]

template<class T >
SparseMatrix< T > operator* ( const SparseMatrix< T > &  matrix,
const F32  scalar 
)
related

SparseMatrix-Scalar post-multiply.

◆ operator*() [3/6]

template<class T >
SparseMatrix< T > operator* ( const F32  scalar,
const SparseMatrix< T > &  matrix 
)
related

SparseMatrix-Scalar pre-multiply.

◆ operator*() [4/6]

template<class T , class ROW >
DenseVector< T > operator* ( const SparseMatrix< T, ROW > &  lhs,
const DenseVector< T > &  rhs 
)
related

SparseMatrix-Vector multiply.

◆ operator*() [5/6]

template<class T , class ROW , class U >
SparseMatrix< T, ROW > operator* ( const SparseMatrix< T, ROW > &  matrix,
const U  scalar 
)
related

SparseMatrix-Scalar post-multiply.

◆ operator*() [6/6]

template<class T , class ROW , class U >
SparseMatrix< T, ROW > operator* ( const U  scalar,
const SparseMatrix< T, ROW > &  matrix 
)
related

SparseMatrix-Scalar pre-multiply.

◆ operator*=()

template<class T , class ROW >
SparseMatrix< T, ROW > & operator*= ( SparseMatrix< T, ROW > &  lhs,
const F32  scalar 
)
related

SparseMatrix-Scalar multiply in place.

◆ operator+() [1/2]

template<class T >
SparseMatrix< T > operator+ ( const SparseMatrix< T > &  lhs,
const SparseMatrix< T > &  rhs 
)
related

◆ operator+() [2/2]

template<class T , class ROW >
SparseMatrix< T, ROW > operator+ ( const SparseMatrix< T, ROW > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

◆ operator+=()

template<class T , class ROW >
SparseMatrix< T, ROW > & operator+= ( SparseMatrix< T, ROW > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix add in place.

◆ operator-() [1/2]

template<class T >
SparseMatrix< T > operator- ( const SparseMatrix< T > &  lhs,
const SparseMatrix< T > &  rhs 
)
related

SparseMatrix subtract.

◆ operator-() [2/2]

template<class T , class ROW >
SparseMatrix< T, ROW > operator- ( const SparseMatrix< T, ROW > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix subtract.

◆ operator-=()

template<class T , class ROW >
SparseMatrix< T, ROW > & operator-= ( SparseMatrix< T, ROW > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix subtract in place.

◆ postmultiplyDiagonal()

template<class T , class ROW >
SparseMatrix< T, ROW > & postmultiplyDiagonal ( SparseMatrix< T, ROW > &  result,
const SparseMatrix< T, ROW > &  lhs,
const DenseVector< T > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where second matrix is a diagonal.

The diagonal matrix is represented as a vector.

The result argument can be used to avoid the expensive allocation of a temporary. The same object is returned by reference for efficient operation in a compound expression.

◆ postmultiplyInverseDiagonal() [1/2]

template<class T , class ROW >
SparseMatrix< T, ROW > & postmultiplyInverseDiagonal ( SparseMatrix< T, ROW > &  result,
const SparseMatrix< T, ROW > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where second matrix is presumed diagonal.

Diagonal elements of the first matrix are inverted during the multiply. Non-diagonal elements of the first matrix are ignored and treated as zero.

The result argument can be used to avoid the expensive allocation of a temporary. The same object is returned by reference for efficient operation in a compound expression.

◆ postmultiplyInverseDiagonal() [2/2]

template<class T , class ROW >
SparseMatrix< T, ROW > & postmultiplyInverseDiagonal ( SparseMatrix< T, ROW > &  result,
const SparseMatrix< T, ROW > &  lhs,
const DenseVector< T > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where second matrix is a diagonal represented by a vector.

Diagonal elements of the first matrix are inverted during the multiply. Non-diagonal elements of the first matrix are ignored and treated as zero.

The result argument can be used to avoid the expensive allocation of a temporary. The same object is returned by reference for efficient operation in a compound expression.

◆ premultiplyDiagonal() [1/4]

template<class T >
SparseMatrix< T > premultiplyDiagonal ( const SparseMatrix< T > &  lhs,
const SparseMatrix< T > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where first matrix is a diagonal.

◆ premultiplyDiagonal() [2/4]

template<class T , class ROW >
void premultiplyDiagonal ( DenseVector< T > &  result,
const SparseMatrix< T, ROW > &  diagonal,
const DenseVector< T > &  vector 
)
related

Compute the per-element product of the vector and the diagonal entries.

Only the diagonal elements are used. The non-diagonal values are not read and treated as zero.

◆ premultiplyDiagonal() [3/4]

template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyDiagonal ( SparseMatrix< T, ROW > &  result,
const DenseVector< T > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where first matrix is presumed diagonal.

The diagonal matrix is represented as a vector.

The result argument can be used to avoid the expensive allocation of a temporary. The same object is returned by reference for efficient operation in a compound expression.

◆ premultiplyDiagonal() [4/4]

template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyDiagonal ( SparseMatrix< T, ROW > &  result,
const SparseMatrix< T, ROW > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where first matrix is presumed diagonal.

Non-diagonal elements of the first matrix are ignored and treated as zero.

The result argument can be used to avoid the expensive allocation of a temporary. The same object is returned by reference for efficient operation in a compound expression.

◆ premultiplyInverseDiagonal() [1/3]

template<class T , class ROW >
void premultiplyInverseDiagonal ( DenseVector< T > &  result,
const SparseMatrix< T, ROW > &  diagonal,
const DenseVector< T > &  vector 
)
related

Compute the per-element product of the vector and the inverse diagonal entries.

Only the diagonal elements are used. The non-diagonal values are not read and treated as zero.

◆ premultiplyInverseDiagonal() [2/3]

template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyInverseDiagonal ( SparseMatrix< T, ROW > &  result,
const SparseMatrix< T, ROW > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where first matrix is presumed diagonal.

Diagonal elements of the first matrix are inverted during the multiply. Non-diagonal elements of the first matrix are ignored and treated as zero.

The result argument can be used to avoid the expensive allocation of a temporary. The same object is returned by reference for efficient operation in a compound expression.

◆ premultiplyInverseDiagonal() [3/3]

template<class T , class ROW >
SparseMatrix< T, ROW > & premultiplyInverseDiagonal ( SparseMatrix< T, ROW > &  result,
const DenseVector< T > &  lhs,
const SparseMatrix< T, ROW > &  rhs 
)
related

SparseMatrix-SparseMatrix multiply where first matrix is a diagonal represented with a vector.

Diagonal elements of the first matrix are inverted during the multiply. Non-diagonal elements of the first matrix are ignored and treated as zero.

The result argument can be used to avoid the expensive allocation of a temporary. The same object is returned by reference for efficient operation in a compound expression.

◆ print()

template<class T >
String print ( const SparseMatrix< T > &  matrix)
related

SparseMatrix print.

The output isn't sparse.

◆ setIdentity() [1/2]

template<class T >
SparseMatrix< T > & setIdentity ( SparseMatrix< T > &  matrix)
related

Set matrix to identity matrix.

◆ setIdentity() [2/2]

template<class T , class ROW >
SparseMatrix< T, ROW > & setIdentity ( SparseMatrix< T, ROW > &  matrix)
related

Set matrix to identity matrix.

◆ transformVector()

template<class T , class ROW >
void transformVector ( const SparseMatrix< T, ROW > &  lhs,
const DenseVector< T > &  in,
DenseVector< T > &  out 
)
related

SparseMatrix-Vector multiply with matrix.

◆ transpose() [1/2]

template<class T >
SparseMatrix< T > transpose ( const SparseMatrix< T > &  matrix)
related

Return transpose of matrix.

◆ transpose() [2/2]

template<class T , class ROW >
SparseMatrix< T, ROW > transpose ( const SparseMatrix< T, ROW > &  matrix)
related

Return transpose of matrix.

◆ transposeMultiply()

template<class T >
DenseVector< T > transposeMultiply ( const SparseMatrix< T > &  lhs,
const DenseVector< T > &  rhs 
)
related

SparseMatrix-Vector multiply with matrix transposed.

◆ transposeTransformVector()

template<class T , class ROW >
void transposeTransformVector ( const SparseMatrix< T, ROW > &  lhs,
const DenseVector< T > &  in,
DenseVector< T > &  out 
)
related

SparseMatrix-Vector multiply with matrix transposed.

◆ width()

template<class T , class ROW >
U32 width ( const SparseMatrix< T, ROW > &  matrix)
related

Return the horizonatal dimension.


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