cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
nmrSVDRSSolver Class Reference

#include <nmrSVDRSSolver.h>

Public Member Functions

 nmrSVDRSSolver (void)
 
 nmrSVDRSSolver (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, CISSTNETLIB_INTEGER nb=1)
 
 nmrSVDRSSolver (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &B)
 
void Allocate (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, CISSTNETLIB_INTEGER nb=1)
 
void Allocate (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &B)
 
void Solve (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &B) throw (std::runtime_error)
 
const vctDynamicMatrix
< CISSTNETLIB_DOUBLE > & 
GetS (void) const
 

Protected Attributes

CISSTNETLIB_INTEGER M
 
CISSTNETLIB_INTEGER N
 
CISSTNETLIB_INTEGER Lda
 
CISSTNETLIB_INTEGER Ldb
 
CISSTNETLIB_INTEGER Nb
 
vctDynamicMatrix
< CISSTNETLIB_DOUBLE > 
S
 
vctDynamicMatrix
< CISSTNETLIB_DOUBLE > 
Work
 

Detailed Description

Algorithm SVDRS: Singular Value Decomposition also treating Right Side Vector.

The original version of this code was developed by Charles L. Lawson and Richard J. Hanson at Jet Propulsion Laboratory 1974 SEP 25, and published in the book "Solving Least Squares Problems", Prentice-Hall, 1974.

This subroutine computes the singular value decomposition of the given $ M \times N $ matrix A, and optionally applies the transformations from the left to the $ Nb $ column vectors of the $ Mb \times Nb $ matrix B. Either $ M > N $ or $ M < N $ is permitted.

The singular value decomposition of A is of the form:

$ A = U S V^{T} $

where U is $ M \times M $ orthogonal, S is $ M \times N $ diagonal with the diagonal terms nonnegative and ordered from large to small, and V is $ N \times N $ orthogonal. Note that these matrices also satisfy:

$ S = (U^{T}) A V $

The singular values, i.e. the diagonal terms of the matrix S, are returned in the matrix GetS(). If $ M < N $, positions $ M+1 $ through N of S() will be set to zero.

The product matrix $ G = U^{T} B $ replaces the given matrix B in the matrix B(,).

If the user wishes to obtain a minimum length least squares solution of the linear system:

$ \| Ax - B \| $

the solution X can be constructed, following use of this subroutine, by computing the sum for i = 1, ..., R of the outer products

(Col i of V) * (1/S(i)) * (Row i of G)

Here R denotes the pseudorank of A which the user may choose in the range 0 through $ \mbox{min}(M, N) $ based on the sizes of the singular values.

The data members of this class are:

Note
This code gives special treatment to rows and columns that are entirely zero. This causes certain zero singular values to appear as exact zeros rather than as about MACHEPS times the largest singular value It similarly cleans up the associated columns of U and V.
The input matrices of this class must use a column major storage order. To do so, use VCT_COL_MAJOR whenever you declare a matrix. They must also be compact (see vctDynamicMatrix::IsFortran()).
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.

Constructor & Destructor Documentation

nmrSVDRSSolver::nmrSVDRSSolver ( 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.

nmrSVDRSSolver::nmrSVDRSSolver ( CISSTNETLIB_INTEGER  m,
CISSTNETLIB_INTEGER  n,
CISSTNETLIB_INTEGER  nb = 1 
)
inline

Constructor with memory allocation. This constructor allocates the memory based on M, N and Nb. 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
nbNumber of columns of B
nmrSVDRSSolver::nmrSVDRSSolver ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  A,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  B 
)
inline

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.

Member Function Documentation

void nmrSVDRSSolver::Allocate ( CISSTNETLIB_INTEGER  m,
CISSTNETLIB_INTEGER  n,
CISSTNETLIB_INTEGER  nb = 1 
)
inline

This method allocates the memory based on M, N and Nb. 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
nbNumber of columns of B
void nmrSVDRSSolver::Allocate ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  A,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  B 
)
inline

Allocate memory to solve this problem. This method provides 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.

const vctDynamicMatrix<CISSTNETLIB_DOUBLE>& nmrSVDRSSolver::GetS ( void  ) const
inline
void nmrSVDRSSolver::Solve ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  A,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  B 
)
throw (std::runtime_error
)
inline

This subroutine computes the singular value decomposition of the given $ M \times N $ matrix A, and optionally applies the transformations from the left to the $ Nb $ column vectors of the $ Mb \times Nb $ matrix B. Either $ M > N $ or $ M < N $ is permitted.

The singular value decomposition of A is of the form:

$ A = U S V^{T} $

Note
This method verifies that the input parameters are using a column major storage order and that they are compact. Both conditions are tested using vctDynamicMatrix::IsFortran(). If the parameters don't meet all the requirements, an exception is thrown (std::runtime_error).

Member Data Documentation

CISSTNETLIB_INTEGER nmrSVDRSSolver::Lda
protected
CISSTNETLIB_INTEGER nmrSVDRSSolver::Ldb
protected
CISSTNETLIB_INTEGER nmrSVDRSSolver::M
protected
CISSTNETLIB_INTEGER nmrSVDRSSolver::N
protected
CISSTNETLIB_INTEGER nmrSVDRSSolver::Nb
protected
vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrSVDRSSolver::S
protected
vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrSVDRSSolver::Work
protected

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