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

#include <nmrLSISolver.h>

Public Member Functions

 nmrLSISolver (void)
 nmrLSISolver (CISSTNETLIB_INTEGER ma, CISSTNETLIB_INTEGER na, CISSTNETLIB_INTEGER mg)
 nmrLSISolver (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &C, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &d, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &b)
void Allocate (CISSTNETLIB_INTEGER ma, CISSTNETLIB_INTEGER na, CISSTNETLIB_INTEGER mg)
void Allocate (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &C, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &d, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &b)
CISST_EXPORT void Solve (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &C, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &d, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &b) throw (std::runtime_error)
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetX (void) const

Protected Attributes

CISSTNETLIB_INTEGER Ma
CISSTNETLIB_INTEGER Na
CISSTNETLIB_INTEGER Mg
vctDynamicMatrix< CISSTNETLIB_DOUBLE > VSiUtb
vctDynamicMatrix< CISSTNETLIB_DOUBLE > GTilde
vctDynamicMatrix< CISSTNETLIB_DOUBLE > HTilde
vctDynamicMatrix< CISSTNETLIB_DOUBLE > Z
vctDynamicMatrix< CISSTNETLIB_DOUBLE > X
vctDynamicMatrix< CISSTNETLIB_DOUBLE > Si
vctDynamicMatrix< CISSTNETLIB_DOUBLE > VSi
nmrSVDRSSolver SVDRS
nmrLDPSolver LDP

Detailed Description

Algorithm LSI: Least Squares with Inequality Constraints.

This code is a re-written version of algorithm from Charles L. Lawson and Richard J. Hanson, "Solving Least Squares Problems", Prentice-Hall, 1974. Section 5: Chapter 23.

Given a \(Ma \times Na\) matrix C, a \(Ma \times 1\) vector d, a \(Mg \times Na\) A and a \(Mg \times 1\) vector b, compute a \(Na \times 1\) vector X, that solves the least squares problem:

\( \mbox{min} \; 1 / 2 \| CX - d \| \; \mbox{subject to} \; AX \geq B\)

The data members of this class are:

  • Ma, Na: Dimension of input matrix C
  • Mg, Na: Dimension of input matrix A
  • VSiUtb: \( \mbox{max}(Ma, Na) \times 1 \) contains \( VS^{-1}U^{T}d \)
  • GTilde: \( Mg \times Na \) contains \( \tilde{G} \). See L&H book for definition of \( \tilde{G} \).
  • HTilde: \( Mg \times 1 \) contains \( \tilde{H} \). See L&H book for definition of \( \tilde{H} \).
  • Z: \( Na \times 1 \) contains solution of the internal LDP problem
  • X: \( Na \times 1 \), on exit contains the solution.
  • Si: \( Na \times Ma \) contains the pseudo inverse of singular values.
  • VSi: \( Na \times Na \) contains \( VS^{-1} \)
Note
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

◆ nmrLSISolver() [1/3]

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

◆ nmrLSISolver() [2/3]

nmrLSISolver::nmrLSISolver ( CISSTNETLIB_INTEGER ma,
CISSTNETLIB_INTEGER na,
CISSTNETLIB_INTEGER mg )
inline

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

Parameters
maNumber of rows of C
naNumber of columns of C
mgNumber of rows of A

◆ nmrLSISolver() [3/3]

nmrLSISolver::nmrLSISolver ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > & C,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > & d,
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

◆ Allocate() [1/2]

void nmrLSISolver::Allocate ( CISSTNETLIB_INTEGER ma,
CISSTNETLIB_INTEGER na,
CISSTNETLIB_INTEGER mg )
inline

This method allocates the memory based on Ma, Na and Mg. The next call to the Solve() method will check that the parameters match the dimension.

Parameters
maNumber of rows of C
naNumber of columns of C
mgNumber of rows of A

◆ Allocate() [2/2]

void nmrLSISolver::Allocate ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > & C,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > & d,
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.

◆ GetX()

const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & nmrLSISolver::GetX ( void ) const
inline

Get X. This method must be used after Solve().

◆ Solve()

CISST_EXPORT void nmrLSISolver::Solve ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > & C,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > & d,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > & A,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > & b )
throw (std::runtime_error )

Given a \(Ma \times Na\) matrix C, a \(Ma \times 1\) vector d, a \(Mg \times Na\) A and a \(Mg \times 1\) vector b, compute a \(Na \times 1\) vector X, that solves the least squares problem:

\( \mbox{min} \; 1 / 2 \| CX - d \| \; \mbox{subject to} \; AX \geq B\)

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

◆ GTilde

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrLSISolver::GTilde
protected

◆ HTilde

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrLSISolver::HTilde
protected

◆ LDP

nmrLDPSolver nmrLSISolver::LDP
protected

◆ Ma

CISSTNETLIB_INTEGER nmrLSISolver::Ma
protected

◆ Mg

CISSTNETLIB_INTEGER nmrLSISolver::Mg
protected

◆ Na

CISSTNETLIB_INTEGER nmrLSISolver::Na
protected

◆ Si

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrLSISolver::Si
protected

◆ SVDRS

nmrSVDRSSolver nmrLSISolver::SVDRS
protected

◆ VSi

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrLSISolver::VSi
protected

◆ VSiUtb

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrLSISolver::VSiUtb
protected

◆ X

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrLSISolver::X
protected

◆ Z

vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrLSISolver::Z
protected

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