If $A\in R^{m\times n}, b\in R^m, c\in R^n$,
if I need to solve the least square problems via SVD of $A$ and $A^T$, i.e.
I need to solve the least square solutions to following linear systems via SVD:
$Ax=b_i,\quad i=1,2,3,\cdots$
$A^Ty=c_j,\;j=1,2,3,\cdots$
it is also possible to do these via householderQr().solve()
in Eigen, but it is instable; So I want to do this via SVD
decomposition of $A$ and $A^T$; obviously, the SVD
of $A^T$ can be obtained by the transpose of that for $A$.
My question is, how can I implement it in Eigen so that only SVD on $A$ is Ok to solve both the two type least square problems?
int m=100,n=50;
VectorXd b=VectorXd::randome(m),c=VectorXd::randome(n);
MatrixXd A=MatrixXd::random(m,n);
Eigen::JacobiSVD<Eigen::MatrixXd> _svd(A, Eigen::ComputeThinU | Eigen::ComputeThinV);
MatrixXd x = _svd.solve(b);
A.transposeInPlace();
// How can I save this sentence below which implements the SVD of $A^T$
Eigen::JacobiSVD<Eigen::MatrixXd> _svd(A, Eigen::ComputeThinU | Eigen::ComputeThinV);
MatrixXd y = _svd.solve(c);