Solve a non-negative least-squares problem with the LARS algorithm (see nonnegativeLeastSquares()) or the Goldfarb-Idnani algorithm (see quadraticProgramming())
Usage: example_nnlsq
(no parameters - example data are defined in nnlsq.cxx)
#include <iostream>
#include <vigra/matrix.hxx>
#include <vigra/regression.hxx>
#include <vigra/quadprog.hxx>
double A_data[] = {
1, -3, 2,
-3, 10, -5,
2, -5, 6
};
double b_data[] = {
27,
-78,
64
};
int main()
{
std::cout << "solution LARS: ";
for(int k=0; k<3; ++k)
std::cout << x(k,0) << ", ";
std::cout << "\n";
zeros(Shape2(3,1)),
empty,
U = transpose(A)*A,
v = -transpose(A)*b;
x = 0;
std::cout << "solution Goldfarb-Idnani: ";
for(int k=0; k<3; ++k)
std::cout << x(k,0) << ", ";
std::cout << "\n";
}
Definition matrix.hxx:125
Linear algebra functions.
Definition eigensystem.hxx:50
void identityMatrix(MultiArrayView< 2, T, C > &r)
Definition matrix.hxx:845
unsigned int quadraticProgramming(...)
unsigned int nonnegativeLeastSquares(...)