![]() |
Eigen-unsupported
3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
|
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.
Public Types | |
typedef Matrix< Scalar, RowsAtCompileTime, 1 > | RhsVectorType |
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 (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. | |
typedef Matrix<Scalar, RowsAtCompileTime, 1> Eigen::NNLS< MatrixType_ >::RhsVectorType |
Type of a column vector of the system matrix \(A\).
typedef Matrix<Scalar, ColsAtCompileTime, 1> Eigen::NNLS< MatrixType_ >::SolutionVectorType |
Type of a row vector of the system matrix \(A\).
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\)). |
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.
|
inline |
|
inline |
|
inline |
|
inline |
Sets the max number of iterations. Default is twice the number of columns of the matrix. The algorithm requires at least k iterations to produce a solution vector with k non-zero entries.
|
inline |
Sets the tolerance threshold used by the stopping criteria.
This is an absolute tolerance on the gradient of the Lagrangian, \(A^T(Ax-b)-\lambda\) (with Lagrange multipliers \(\lambda\)).
const NNLS< MatrixType >::SolutionVectorType & Eigen::NNLS< MatrixType >::solve | ( | const RhsVectorType & | b | ) |
|
inline |