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

#include <nmrNNLSSolver.h>

Public Member Functions

 nmrNNLSSolver (void)
 
 nmrNNLSSolver (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n)
 
 nmrNNLSSolver (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &C, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &d)
 
void Allocate (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n)
 
void Allocate (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &C, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &CMN_UNUSED(d))
 
void Solve (vctDynamicMatrix< CISSTNETLIB_DOUBLE > &C, vctDynamicMatrix< CISSTNETLIB_DOUBLE > d) throw (std::runtime_error)
 
const vctDynamicMatrix
< CISSTNETLIB_DOUBLE > & 
GetX (void) const
 
const vctDynamicMatrix
< CISSTNETLIB_DOUBLE > & 
GetDual (void) const
 
CISSTNETLIB_DOUBLE GetRNorm (void) const
 

Protected Attributes

CISSTNETLIB_INTEGER M
 
CISSTNETLIB_INTEGER N
 
CISSTNETLIB_INTEGER Mda
 
CISSTNETLIB_INTEGER Mode
 
CISSTNETLIB_DOUBLE RNorm
 
vctDynamicMatrix
< CISSTNETLIB_DOUBLE > 
X
 
vctDynamicMatrix
< CISSTNETLIB_DOUBLE > 
W
 
vctDynamicMatrix
< CISSTNETLIB_DOUBLE > 
Zz
 
vctDynamicMatrix
< CISSTNETLIB_INTEGER > 
Index
 

Detailed Description

Algorithm NNLS: Non Negative Least Squares

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

Given a $ M \times N$ matrix A, and a $ M \times 1 $ vector B, compute a $ N \times 1 $ vector X, that solves the least squares problem:

$ \mbox{min} \; 1 / 2 \| AX - B \| \; \mbox{subject to} \; X \geq 0$

The data members of this class are:

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

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

nmrNNLSSolver::nmrNNLSSolver ( CISSTNETLIB_INTEGER  m,
CISSTNETLIB_INTEGER  n 
)
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 C
nNumber of columns of C
nmrNNLSSolver::nmrNNLSSolver ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  C,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  d 
)
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 nmrNNLSSolver::Allocate ( CISSTNETLIB_INTEGER  m,
CISSTNETLIB_INTEGER  n 
)
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 C
nNumber of columns of C
void nmrNNLSSolver::Allocate ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  C,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  CMN_UNUSED
)
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>& nmrNNLSSolver::GetDual ( void  ) const
inline
CISSTNETLIB_DOUBLE nmrNNLSSolver::GetRNorm ( void  ) const
inline
const vctDynamicMatrix<CISSTNETLIB_DOUBLE>& nmrNNLSSolver::GetX ( void  ) const
inline

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

void nmrNNLSSolver::Solve ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  C,
vctDynamicMatrix< CISSTNETLIB_DOUBLE >  d 
)
throw (std::runtime_error
)
inline

Given a $ M \times N$ matrix A, and a $ M \times 1 $ vector B, compute a $ N \times 1 $ vector X, that solves the least squares problem:

$ \mbox{min} \; 1 / 2 \| AX - B \| \; \mbox{subject to} \; X \geq 0$

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

vctDynamicMatrix<CISSTNETLIB_INTEGER> nmrNNLSSolver::Index
protected
CISSTNETLIB_INTEGER nmrNNLSSolver::M
protected
CISSTNETLIB_INTEGER nmrNNLSSolver::Mda
protected
CISSTNETLIB_INTEGER nmrNNLSSolver::Mode
protected
CISSTNETLIB_INTEGER nmrNNLSSolver::N
protected
CISSTNETLIB_DOUBLE nmrNNLSSolver::RNorm
protected
vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrNNLSSolver::W
protected
vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrNNLSSolver::X
protected
vctDynamicMatrix<CISSTNETLIB_DOUBLE> nmrNNLSSolver::Zz
protected

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