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

#include <nmrLSSolver.h>

Public Member Functions

 nmrLSSolver (void)
 nmrLSSolver (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, CISSTNETLIB_INTEGER nrhs, bool storageOrder)
 nmrLSSolver (vctDynamicMatrix< double > &A, vctDynamicMatrix< double > &B)
void Allocate (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, CISSTNETLIB_INTEGER nrhs, bool storageOrder)
void Allocate (vctDynamicMatrix< double > &A, vctDynamicMatrix< double > &B)
template<class _matrixOwnerType>
void Solve (vctDynamicMatrixBase< _matrixOwnerType, double > &A, vctDynamicMatrixBase< _matrixOwnerType, double > &B) CISST_THROW(std

Protected Attributes

CISSTNETLIB_INTEGER M
CISSTNETLIB_INTEGER N
CISSTNETLIB_INTEGER NRHS
CISSTNETLIB_INTEGER Lda
CISSTNETLIB_INTEGER Ldb
CISSTNETLIB_INTEGER Lwork
char Trans
vctDynamicMatrix< double > Work
CISSTNETLIB_INTEGER Info
bool StorageOrder

Detailed Description

Algorithm LS: Least Squares by QR or LQ decomposition This solves overdetermined or underdetermined real linear systems involving an M-by-N matrix A, or its transpose, using a QR or LQ factorization of A. It is assumed that A has full rank.

The following options are provided:

  1. If m >= n: find the least squares solution of an overdetermined system, i.e., solve the least squares problem \( \mbox {minimize} \| B - A*X \| \)
  2. If m < n: find the minimum norm solution of an underdetermined system \( A * X = B \)

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 \).
  • NRHS: The number of right hand sides, i.e., the number of columns of the matrices B and X. \( NRHS >=0 \).
  • Lda: The leading dimension of the array A. \( Lda \geq \mbox{max}(1,M) \).
  • Ldb: The leading dimension of the array B. \( Ldb \geq \mbox{max}(1,M,N). \).
  • Lwork: The dimension of the matrix Work. \( Lwork \geq \mbox{max}( 1, MN + max( MN, NRHS ) )\). For optimal performance, \( Lwork \geq \mbox{max}( 1, MN + max( MN, NRHS )*NB )\). where \( MN = \mbox{min}(M,N) \) and \( NB \) is the optimum block size.
  • Info: = 0: successful exit < 0: argument had an illegal value
  • Work: Working matrix of dimenstion \( Lwork \times 1 \).

The input/output from this class is:

  • A: On entry, the \( M \times N \) matrix A. On exit, if M >= N, A is overwritten by details of its QR factorization if M < N, A is overwritten by details of its LQ factorization
  • B: On entry, the matrix B of right hand side vectors, stored columnwise; B is M-by-NRHS On exit, B is overwritten by the solution vectors, stored columnwise: if m >= n, rows 1 to n of B contain the least squares solution vectors; the residual sum of squares for the solution in each column is given by the sum of squares of elements N+1 to M in that column; if m < n, rows 1 to N of B contain the minimum norm solution vectors;
Note
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.

Constructor & Destructor Documentation

◆ nmrLSSolver() [1/3]

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

◆ nmrLSSolver() [2/3]

nmrLSSolver::nmrLSSolver ( CISSTNETLIB_INTEGER m,
CISSTNETLIB_INTEGER n,
CISSTNETLIB_INTEGER nrhs,
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
nrhsNumber of columns of B
storageOrderStorage order used for the input matrix. This order will be used for the output as well.

◆ nmrLSSolver() [3/3]

nmrLSSolver::nmrLSSolver ( vctDynamicMatrix< double > & A,
vctDynamicMatrix< 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 and storage order.

Member Function Documentation

◆ Allocate() [1/2]

void nmrLSSolver::Allocate ( CISSTNETLIB_INTEGER m,
CISSTNETLIB_INTEGER n,
CISSTNETLIB_INTEGER nrhs,
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
nrhsNumber of columns of B
storageOrderStorage order used for all the matrices

◆ Allocate() [2/2]

void nmrLSSolver::Allocate ( vctDynamicMatrix< double > & A,
vctDynamicMatrix< 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.

◆ Solve()

template<class _matrixOwnerType>
void nmrLSSolver::Solve ( vctDynamicMatrixBase< _matrixOwnerType, double > & A,
vctDynamicMatrixBase< _matrixOwnerType, double > & B )
inline

This computes the solves overdetermined or underdetermined real linear systems involving an M-by-N matrix A, using the right hand side M-by-NRHS matrix B.

Member Data Documentation

◆ Info

CISSTNETLIB_INTEGER nmrLSSolver::Info
protected

◆ Lda

CISSTNETLIB_INTEGER nmrLSSolver::Lda
protected

◆ Ldb

CISSTNETLIB_INTEGER nmrLSSolver::Ldb
protected

◆ Lwork

CISSTNETLIB_INTEGER nmrLSSolver::Lwork
protected

◆ M

CISSTNETLIB_INTEGER nmrLSSolver::M
protected

◆ N

CISSTNETLIB_INTEGER nmrLSSolver::N
protected

◆ NRHS

CISSTNETLIB_INTEGER nmrLSSolver::NRHS
protected

◆ StorageOrder

bool nmrLSSolver::StorageOrder
protected

◆ Trans

char nmrLSSolver::Trans
protected

◆ Work

vctDynamicMatrix<double> nmrLSSolver::Work
protected

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