Implementation of the Non-Negative Least Squares (NNLS) algorithm. More...
Public Types | |
enum | { RowsAtCompileTime , ColsAtCompileTime , Options , MaxRowsAtCompileTime , MaxColsAtCompileTime } |
typedef MatrixType::Index | Index |
typedef Matrix< Index, ColsAtCompileTime, 1 > | IndicesType |
typedef MatrixType_ | MatrixType |
typedef MatrixType::RealScalar | RealScalar |
typedef Matrix< Scalar, RowsAtCompileTime, 1 > | RhsVectorType |
typedef MatrixType::Scalar | Scalar |
typedef Matrix< Scalar, ColsAtCompileTime, 1 > | SolutionVectorType |
Public Member Functions | |
template<typename MatrixDerived > | |
NNLS< MatrixType > & | compute (const EigenBase< MatrixDerived > &A) |
ComputationInfo | info () const |
Index | iterations () const |
Index | maxIterations () const |
NNLS () | |
NNLS (const MatrixType &A, Index max_iter=-1, Scalar tol=NumTraits< Scalar >::dummy_precision()) | |
Constructs a NNLS sovler and initializes it with the given system matrix A . More... | |
NNLS< MatrixType > & | setMaxIterations (Index maxIters) |
NNLS< MatrixType > & | setTolerance (const Scalar &tolerance) |
const SolutionVectorType & | solve (const RhsVectorType &b) |
Solves the NNLS problem. More... | |
Scalar | tolerance () const |
const SolutionVectorType & | x () const |
Returns the solution if a problem was solved. If not, an uninitialized vector may be returned. More... | |
Private Types | |
typedef Matrix< Scalar, ColsAtCompileTime, ColsAtCompileTime > | MatrixAtAType |
Private Member Functions | |
void | moveToActiveSet_ (Index idx) |
void | moveToInactiveSet_ (Index idx) |
void | solveInactiveSet_ (const RhsVectorType &b) |
Implementation of the Non-Negative Least Squares (NNLS) algorithm.
MatrixType | The type of the system matrix \(A\). |
This class implements the NNLS algorithm as described in "SOLVING LEAST SQUARES PROBLEMS", Charles L. Lawson and Richard J. Hanson, Prentice-Hall, 1974. This algorithm solves a least squares problem iteratively and ensures that the solution is non-negative. I.e.
\[ \min \left\Vert Ax-b\right\Vert_2^2\quad s.t.\, x\ge 0 \]
The algorithm solves the constrained least-squares problem above by iteratively improving an estimate of which constraints are active (elements of \(x\) equal to zero) and which constraints are inactive (elements of \(x\) greater than zero). Each iteration, an unconstrained linear least-squares problem solves for the components of \(x\) in the (estimated) inactive set and the sets are updated. The unconstrained problem minimizes \(\left\Vert A^Nx^N-b\right\Vert_2^2\), where \(A^N\) is a matrix formed by selecting all columns of A which are in the inactive set \(N\).
See the wikipedia page on non-negative least squares for more background information.
typedef MatrixType::Index Eigen::NNLS< MatrixType_ >::Index |
typedef Matrix<Index, ColsAtCompileTime, 1> Eigen::NNLS< MatrixType_ >::IndicesType |
|
private |
typedef MatrixType_ Eigen::NNLS< MatrixType_ >::MatrixType |
typedef MatrixType::RealScalar Eigen::NNLS< MatrixType_ >::RealScalar |
typedef Matrix<Scalar, RowsAtCompileTime, 1> Eigen::NNLS< MatrixType_ >::RhsVectorType |
typedef MatrixType::Scalar Eigen::NNLS< MatrixType_ >::Scalar |
typedef Matrix<Scalar, ColsAtCompileTime, 1> Eigen::NNLS< MatrixType_ >::SolutionVectorType |
anonymous enum |
Eigen::NNLS< MatrixType >::NNLS |
Eigen::NNLS< MatrixType >::NNLS | ( | const MatrixType & | A, |
Index | max_iter = -1 , |
||
Scalar | tol = NumTraits<Scalar>::dummy_precision() |
||
) |
Constructs a NNLS sovler and initializes it with the given system matrix A
.
A | Specifies the system matrix. |
max_iter | Specifies the maximum number of iterations to solve the system. |
tol | Specifies the precision of the optimum. This is an absolute tolerance on the gradient of the Lagrangian, \(A^T(Ax-b)-\lambda\) (with Lagrange multipliers \(\lambda\)). |
Definition at line 217 of file NNLS.
NNLS< MatrixType > & Eigen::NNLS< MatrixType >::compute | ( | const EigenBase< MatrixDerived > & | A | ) |
Initializes the solver with the matrix A for further solving NNLS problems.
This function mostly initializes/computes the preconditioner. In the future we might, for instance, implement column reordering for faster matrix vector products.
Definition at line 223 of file NNLS.
|
inline |
|
inline |
|
inline |
|
private |
Definition at line 350 of file NNLS.
|
private |
Definition at line 339 of file NNLS.
|
inline |
|
inline |
const NNLS< MatrixType >::SolutionVectorType & Eigen::NNLS< MatrixType >::solve | ( | const RhsVectorType & | b | ) |
Solves the NNLS problem.
The dimension of b
must be equal to the number of rows of A
, given to the constructor.
Definition at line 248 of file NNLS.
|
private |
|
inline |
Definition at line 124 of file NNLS.
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |