ERC CISST - cisst software

nmrNNLSSolver Class Reference
[Numerical Methods]

#include <nmrNNLSSolver.h>

Collaboration diagram for nmrNNLSSolver:

Collaboration graph
[legend]
List of all members.

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.

Definition at line 72 of file nmrNNLSSolver.h.

Public Member Functions

Protected Attributes


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.

Definition at line 90 of file nmrNNLSSolver.h.

References Allocate(), M, and N.

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:
m Number of rows of C
n Number of columns of C

Definition at line 106 of file nmrNNLSSolver.h.

References Allocate().

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.

Definition at line 116 of file nmrNNLSSolver.h.

References Allocate().


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:
m Number of rows of C
n Number of columns of C

Definition at line 128 of file nmrNNLSSolver.h.

References Index, M, Mda, N, vctDynamicMatrix< _elementType >::SetSize(), VCT_COL_MAJOR, W, X, and Zz.

Referenced by Allocate(), and nmrNNLSSolver().

void nmrNNLSSolver::Allocate ( vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  C,
vctDynamicMatrix< CISSTNETLIB_DOUBLE > &  CMN_UNUSED(d) 
) [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.

Definition at line 143 of file nmrNNLSSolver.h.

References Allocate(), vctDynamicConstMatrixBase< vctDynamicMatrixOwner< _elementType >, _elementType >::cols(), and vctDynamicConstMatrixBase< vctDynamicMatrixOwner< _elementType >, _elementType >::rows().

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).

Definition at line 160 of file nmrNNLSSolver.h.

References cmnThrow(), vctDynamicConstMatrixBase< vctDynamicMatrixOwner< _elementType >, _elementType >::cols(), Index, vctDynamicConstMatrixBase< vctDynamicMatrixOwner< _elementType >, _elementType >::IsFortran(), M, Mda, Mode, N, vctDynamicMatrixBase< vctDynamicMatrixOwner< _elementType >, _elementType >::Pointer(), vctDynamicMatrixBase< _matrixOwnerType, _elementType >::Pointer(), RNorm, vctDynamicConstMatrixBase< vctDynamicMatrixOwner< _elementType >, _elementType >::rows(), W, X, and Zz.

const vctDynamicMatrix<CISSTNETLIB_DOUBLE>& nmrNNLSSolver::GetX ( void   )  const [inline]

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

Definition at line 187 of file nmrNNLSSolver.h.

References X.


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu