I am trying to solve a sparse least-squares like problem using the SparseQR solver in Eigen. In the course of my application, I have to solve for both the over and underdetermined equations provided by some matrix A
where A
is overdetermined and A.transpose()
is underdetermined.
I understand the technique by which the over-determined system is solved reasonably well using QR decomposition, but I wanted to check how Eigen solves the under-determined system. To solve the equation A.transpose() x = b
Eigen doesn't seem to be performing the minimum norm solution which would be performed something like:
//Get the QR decomposition of A (over-determined system)
SparseQR solver;
solver.compute(A)
//Get the Q and R matrices of A
Q = solver.matrixQ()
R = solver.matrixR()
//Given that: A.transpose() = R.transpose() Q.transpose(), solve for x
xstar = R.transpose().solve(b)
x = Q*xstar
but after solving using a solver initialized via
solverAT.compute(AT);
I don't get the minimum-norm solution so I'm not sure exactly what approach it is using.
An additional question is if I can use the overdetermined decomposition to solve the underdetermined problem without having to recompute. That would certainly help in my application.