I have a linear algebraic equation of the form Ax=By
. Where A is a matrix of 6x5
, x
is vector of size 5
, B a matrix of 6x6
and y
vector of size 6. A
, B
and y
are known variables and their values are accessed in real time coming from the sensors. x
is unknown and has to find. One solution is to find Least Square Estimation
that is x = [(A^T*A)^-1]*(A^T)B*y
. This is conventional solution of linear algebraic equations. I used Eigen QR Decomposition
to solve this as below
matrixA = getMatrixA();
matrixB = getMatrixB();
vectorY = getVectorY();
//LSE Solution
Eigen::ColPivHouseholderQR<Eigen::MatrixXd> dec1(matrixA);
vectorX = dec1.solve(matrixB*vectorY);//
Everything is fine until now. But when I check the errore = Ax-By
, its not zero always. Error is not very big but even not ignorable. Is there any other type of decomposition which is more reliable? I have gone through one of the page but could not understand the meaning or how to implement this. Below are lines from the reference how to solve the problem. Could anybody suggest me how to implement this?
The solution of such equations Ax = By
is obtained by forming the error vector e = Ax-By
and the finding the unknown vector x
that minimizes the weighted error (e^T*W*e)
, where W
is a weighting matrix. For simplicity, this weighting matrix is chosen to be of the form W = K*S
, where S
is a constant diagonal scaling matrix, and K
is scalar weight. Hence the solution to the equation becomes
x = [(A^T*W*A)^-1]*(A^T)*W*B*y
I did not understand how to form the matrix W
.