Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Private Attributes
mrpt::math::CSparseMatrix::CholeskyDecomp Class Reference

Detailed Description

Auxiliary class to hold the results of a Cholesky factorization of a sparse matrix.

This implementation does not allow updating/downdating.

Usage example:

CSparseMatrix SM(100,100);
SM.insert_entry(i,j, val); ...
SM.compressFromTriplet();
// Do Cholesky decomposition:
CSparseMatrix::CholeskyDecomp CD(SM);
CD.get_inverse();
...
Note
Only the upper triangular part of the input matrix is accessed.
This class was initially adapted from "robotvision", by Hauke Strasdat, Steven Lovegrove and Andrew J. Davison. See http://www.openslam.org/robotvision.html
This class designed to be "uncopiable".
See also
The main class: CSparseMatrix

Definition at line 440 of file CSparseMatrix.h.

#include <mrpt/math/CSparseMatrix.h>

Public Member Functions

 CholeskyDecomp (const CSparseMatrix &A)
 Constructor from a square definite-positive sparse matrix A, which can be use to solve Ax=b The actual Cholesky decomposition takes places in this constructor. More...
 
 CholeskyDecomp (const CholeskyDecomp &A)=delete
 
CholeskyDecompoperator= (const CholeskyDecomp &)=delete
 
virtual ~CholeskyDecomp ()
 Destructor. More...
 
CMatrixDouble get_L () const
 Return the L matrix (L*L' = M), as a dense matrix. More...
 
void get_L (CMatrixDouble &out_L) const
 Return the L matrix (L*L' = M), as a dense matrix. More...
 
template<class VECTOR >
VECTOR backsub (const VECTOR &b) const
 Return the vector from a back-substitution step that solves: Ux=b. More...
 
void backsub (const Eigen::VectorXd &b, Eigen::VectorXd &result_x) const
 Return the vector from a back-substitution step that solves: Ux=b. More...
 
void backsub (const double *b, double *result, const size_t N) const
 overload for double pointers which assume the user has reserved the output memory for result More...
 
void update (const CSparseMatrix &new_SM)
 Update the Cholesky factorization from an updated vesion of the original input, square definite-positive sparse matrix. More...
 

Private Attributes

css * m_symbolic_structure
 
csn * m_numeric_structure
 
const CSparseMatrixm_originalSM
 A const reference to the original matrix used to build this decomposition. More...
 

Constructor & Destructor Documentation

◆ CholeskyDecomp() [1/2]

CSparseMatrix::CholeskyDecomp::CholeskyDecomp ( const CSparseMatrix SM)

Constructor from a square definite-positive sparse matrix A, which can be use to solve Ax=b The actual Cholesky decomposition takes places in this constructor.

Constructor from a square semidefinite-positive sparse matrix.

Note
Only the upper triangular part of the matrix is accessed.
Exceptions
std::runtime_errorOn non-square input matrix.
mrpt::math::CExceptionNotDefPosOn non-definite-positive matrix as input.

The actual Cholesky decomposition takes places in this constructor.

Exceptions
std::runtime_errorOn non-square input matrix.
mrpt::math::CExceptionNotDefPosOn non-semidefinite-positive matrix as input.

Definition at line 356 of file CSparseMatrix.cpp.

References ASSERT_, mrpt::math::CSparseMatrix::cols(), mrpt::math::CSparseMatrix::isColumnCompressed(), m_numeric_structure, m_originalSM, m_symbolic_structure, mrpt::math::CSparseMatrix::rows(), and mrpt::math::CSparseMatrix::sparse_matrix.

◆ CholeskyDecomp() [2/2]

mrpt::math::CSparseMatrix::CholeskyDecomp::CholeskyDecomp ( const CholeskyDecomp A)
delete

◆ ~CholeskyDecomp()

CSparseMatrix::CholeskyDecomp::~CholeskyDecomp ( )
virtual

Destructor.

Definition at line 378 of file CSparseMatrix.cpp.

Member Function Documentation

◆ backsub() [1/3]

void CSparseMatrix::CholeskyDecomp::backsub ( const double *  b,
double *  result,
const size_t  N 
) const

overload for double pointers which assume the user has reserved the output memory for result

Return the vector from a back-substitution step that solves: Ux=b

Definition at line 400 of file CSparseMatrix.cpp.

References ASSERT_.

◆ backsub() [2/3]

void CSparseMatrix::CholeskyDecomp::backsub ( const Eigen::VectorXd &  b,
Eigen::VectorXd &  result_x 
) const

Return the vector from a back-substitution step that solves: Ux=b.

Return the vector from a back-substitution step that solves: Ux=b

Vectors can be Eigen::VectorXd or mrpt::math::CVectorDouble

Definition at line 391 of file CSparseMatrix.cpp.

References ASSERT_.

◆ backsub() [3/3]

template<class VECTOR >
VECTOR mrpt::math::CSparseMatrix::CholeskyDecomp::backsub ( const VECTOR &  b) const
inline

Return the vector from a back-substitution step that solves: Ux=b.

Definition at line 480 of file CSparseMatrix.h.

◆ get_L() [1/2]

CMatrixDouble mrpt::math::CSparseMatrix::CholeskyDecomp::get_L ( ) const
inline

Return the L matrix (L*L' = M), as a dense matrix.

Definition at line 468 of file CSparseMatrix.h.

Referenced by TEST().

◆ get_L() [2/2]

void CSparseMatrix::CholeskyDecomp::get_L ( CMatrixDouble out_L) const

Return the L matrix (L*L' = M), as a dense matrix.

Definition at line 385 of file CSparseMatrix.cpp.

References mrpt::math::CSparseMatrix::cs2dense().

◆ operator=()

CholeskyDecomp& mrpt::math::CSparseMatrix::CholeskyDecomp::operator= ( const CholeskyDecomp )
delete

◆ update()

void CSparseMatrix::CholeskyDecomp::update ( const CSparseMatrix new_SM)

Update the Cholesky factorization from an updated vesion of the original input, square definite-positive sparse matrix.

NOTE: This new matrix MUST HAVE exactly the same sparse structure than the original one.

Definition at line 424 of file CSparseMatrix.cpp.

References ASSERTMSG_, and mrpt::math::CSparseMatrix::sparse_matrix.

Member Data Documentation

◆ m_numeric_structure

csn* mrpt::math::CSparseMatrix::CholeskyDecomp::m_numeric_structure
private

Definition at line 444 of file CSparseMatrix.h.

Referenced by CholeskyDecomp().

◆ m_originalSM

const CSparseMatrix* mrpt::math::CSparseMatrix::CholeskyDecomp::m_originalSM
private

A const reference to the original matrix used to build this decomposition.

Definition at line 447 of file CSparseMatrix.h.

Referenced by CholeskyDecomp().

◆ m_symbolic_structure

css* mrpt::math::CSparseMatrix::CholeskyDecomp::m_symbolic_structure
private

Definition at line 443 of file CSparseMatrix.h.

Referenced by CholeskyDecomp().

val
int val
Definition: mrpt_jpeglib.h:955
mrpt::math::CSparseMatrix::CSparseMatrix
CSparseMatrix(const size_t nRows=0, const size_t nCols=0)
Create an initially empty sparse matrix, in the "triplet" form.
Definition: CSparseMatrix.cpp:149



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST