cisst-saw
Loading...
Searching...
No Matches
nmrSVDSolver Class Reference

#include <nmrSVDSolver.h>

Public Member Functions

 nmrSVDSolver (void)
 nmrSVDSolver (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, bool storageOrder)
Constructor with memory allocation.

This constructor allocates the memory based on the actual input of the Solve() method. It relies on the method Allocate(). The next call to the Solve() method will check that the parameters match the dimension and storage order.

Parameters
AInput matrix
template<class _matrixOwnerType>
 nmrSVDSolver (const vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A)
template<vct::size_type _rows, vct::size_type _cols, bool _storageOrder>
 nmrSVDSolver (const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > &A)
void Allocate (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, bool storageOrder)
Allocate memory to solve this problem.

This methods provide a convenient way to extract the required sizes from the input containers. The next call to the Solve() method will check that the parameters match the dimension.

template<class _matrixOwnerType>
void Allocate (const vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A)
template<vct::size_type _rows, vct::size_type _cols, bool _storageOrder>
void Allocate (const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > &A)
template<class _matrixOwnerType>
void Solve (vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A) throw (std::runtime_error)
template<vct::size_type _rows, vct::size_type _cols, bool _storageOrder>
void Solve (vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > &A)
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetS (void) const
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetU (void) const
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetVt (void) const

Protected Attributes

CISSTNETLIB_INTEGER M
CISSTNETLIB_INTEGER N
CISSTNETLIB_INTEGER Lda
CISSTNETLIB_INTEGER Ldu
CISSTNETLIB_INTEGER Ldvt
CISSTNETLIB_INTEGER Lwork
char Jobu
char Jobvt
vctDynamicMatrix< CISSTNETLIB_DOUBLE > S
vctDynamicMatrix< CISSTNETLIB_DOUBLE > U
vctDynamicMatrix< CISSTNETLIB_DOUBLE > Vt
vctDynamicMatrix< CISSTNETLIB_DOUBLE > Work
CISSTNETLIB_INTEGER Info
bool StorageOrder

Detailed Description

Algorithm SVD: Singular Value Decomposition

This computes the singular value decomposition (SVD) of a real \( M \times N \) matrix A, optionally computing the left and/or right singular vectors. The SVD is written:

\( A = U * \Sigma * V^{T} \)

where \( \Sigma \) is a \( M \times N \) matrix which is zero except for its min(m,n) diagonal elements, U is a \( M \times M \) orthogonal matrix, and V is a \( N \times N \) orthogonal matrix. The diagonal elements of \( \Sigma \) are the singular values of A; they are real and non-negative, and are returned in descending order. The first \( \mbox{min}(m,n) \) columns of U and V are the left and right singular vectors of A.

Note that the routine returns \( V^{T} \), not \( V \).

The data members of this class are:

  • M: The number of rows of the input matrix A. M >= 0.
  • N: The number of columns of the input matrix A. N >= 0.
  • Lda: The leading dimension of the array A. \( Lda \geq \mbox{max}(1,M) \).
  • Ldu: The leading dimension of the array U. \( Ldu \geq M \).
  • Ldvt: The leading dimension of the array VT. \( Ldvt \geq N \).
  • Lwork: The dimension of the matrix Work. \( Lwork \geq \mbox{max}(3 * \mbox{min}(M,N) + \mbox{max}(M,N), 5 * \mbox{min}(M,N)) \).
  • Work: Working matrix of dimenstion \( Lwork \times 1 \).
  • S: The singular values of A, sorted so that \( S(i) \geq S(i+1) \).
  • U: Contains the \( M \times M \) orthogonal matrix U.
  • Vt: Contains the \( N \times N \) orthogonal matrix \( V^{T} \).
  • A: On entry, the \( M \times N \) matrix A. On exit, the content of A is altered.
Note
The input matrices of this class can use either column major or row major storage order. To select the storage order, use either VCT_COL_MAJOR or VCT_ROW_MAJOR (default) whenever you declare a matrix.
The input matrix must be compact (see vctDynamicMatrix::IsCompact() or vctFixedSizeMatrix::IsCompact()).
This code relies on the ERC CISST cnetlib library. Since cnetlib is optional, make sure that CISST_HAS_CNETLIB has been turned ON during the configuration with CMake.
Deprecated
This class has been replaced by nmrSVD, nmrSVDDynamicData and nmrSVDFixedSizeData.

Constructor & Destructor Documentation

◆ nmrSVDSolver() [1/4]

nmrSVDSolver::nmrSVDSolver ( void )
inline

Default constructor. This constructor doesn't allocate any memory. If you use this constructor, you will need to use one of the Allocate() methods before you can use the Solve method.

◆ nmrSVDSolver() [2/4]

nmrSVDSolver::nmrSVDSolver ( CISSTNETLIB_INTEGER m,
CISSTNETLIB_INTEGER n,
bool storageOrder )
inline

Constructor with memory allocation. This constructor allocates the memory based on M and N. It relies on the method Allocate(). The next call to the Solve() method will check that the parameters match the dimension.

Parameters
mNumber of rows of A
nNumber of columns of A
storageOrderStorage order used for the input matrix. This order will be used for the output as well.

◆ nmrSVDSolver() [3/4]

template<class _matrixOwnerType>
nmrSVDSolver::nmrSVDSolver ( const vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > & A)
inline

◆ nmrSVDSolver() [4/4]

template<vct::size_type _rows, vct::size_type _cols, bool _storageOrder>
nmrSVDSolver::nmrSVDSolver ( const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > & A)
inline

Member Function Documentation

◆ Allocate() [1/3]

void nmrSVDSolver::Allocate ( CISSTNETLIB_INTEGER m,
CISSTNETLIB_INTEGER n,
bool storageOrder )
inline

This method allocates the memory based on M and N. The next call to the Solve() method will check that the parameters match the dimension.

Parameters
mNumber of rows of A
nNumber of columns of A
storageOrderStorage order used for all the matrices

◆ Allocate() [2/3]

template<class _matrixOwnerType>
void nmrSVDSolver::Allocate ( const vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > & A)
inline

◆ Allocate() [3/3]

template<vct::size_type _rows, vct::size_type _cols, bool _storageOrder>
void nmrSVDSolver::Allocate ( const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > & A)
inline

◆ GetS()

const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & nmrSVDSolver::GetS ( void ) const
inline

◆ GetU()

const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & nmrSVDSolver::GetU ( void ) const
inline

◆ GetVt()

const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & nmrSVDSolver::GetVt ( void ) const
inline

◆ Solve() [1/2]

template<class _matrixOwnerType>
void nmrSVDSolver::Solve ( vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > & A)
throw (std::runtime_error )
inline

This computes the singular value decomposition (SVD) of a real \( M \times N \) matrix A, optionally computing the left and/or right singular vectors. The SVD is written:

\( A = U * \Sigma * V^{T} \)

Note
This method requires a compact matrix with the same size and storage order used to Allocate. An std::runtime_error exception will be thrown if these conditions are not met.

◆ Solve() [2/2]

template<vct::size_type _rows, vct::size_type _cols, bool _storageOrder>
void nmrSVDSolver::Solve ( vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > & A)
inline

Member Data Documentation

◆ Info

CISSTNETLIB_INTEGER nmrSVDSolver::Info
protected

◆ Jobu

char nmrSVDSolver::Jobu
protected

◆ Jobvt

char nmrSVDSolver::Jobvt
protected

◆ Lda

CISSTNETLIB_INTEGER nmrSVDSolver::Lda
protected

◆ Ldu

CISSTNETLIB_INTEGER nmrSVDSolver::Ldu
protected

◆ Ldvt

CISSTNETLIB_INTEGER nmrSVDSolver::Ldvt
protected

◆ Lwork

CISSTNETLIB_INTEGER nmrSVDSolver::Lwork
protected

◆ M

CISSTNETLIB_INTEGER nmrSVDSolver::M
protected

◆ N

CISSTNETLIB_INTEGER nmrSVDSolver::N
protected

◆ S

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrSVDSolver::S
protected

◆ StorageOrder

bool nmrSVDSolver::StorageOrder
protected

◆ U

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrSVDSolver::U
protected

◆ Vt

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrSVDSolver::Vt
protected

◆ Work

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrSVDSolver::Work
protected

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