I am trying to find a java code to compute the least squares solution (x) in the Ax=b equation.
A = [1 0 0;1 0 0];
b = [1; 2];
x = A\b
I found Class LeastSquares,
public LeastSquares(double a, double b, int degree)
but in the input both A and B are one dimensional arrays, however, in above example, A is a matrix and B is an array.
In Class NonNegativeLeastSquares
public NonNegativeLeastSquares(int M, int N, double a,double b)
A is a matrix and B is an array, but the description of the class says that it finds an approximate solution to the linear system of equations Ax = b, such that ||Ax - b||2 is minimized, and such that x >= 0. Which means that x must be always positive.
I need a similar class as NonNegativeLeastSquares, however with out the x>=0 constraint.
Could someone please help me?
thanks a lot.