I have a set of linear algebraic equations in matrices form, Ax=By. Where A is matrix of 36x20 and x is a vector of size 20, B is 36x13 and y is 13x1. Rank(A)=20. Because system is overdetermined (there are more number of equations than the variables), so least squares solution is possible, i,e; x = (A^TA)^-1A^TBy. I want the solution so that the residual error e = Ax-By should be minimized.
Using Eigen/Dense library of C++ i have formulated all the matrices etc. I tried the method described on this page
Eigen Tutorial!
I guess the method described in this page is only for square matrices. Because when it try to run this it gives error.
x = A.jacobiSvd( ComputeThinU | ComputeThinV ).solve(B*y);
Error
/usr/include/eigen3/Eigen/src/SVD/JacobiSVD.h: In member function 'const
Eigen::internal::solve_retval<Eigen::JacobiSVD<MatrixType, QRPreconditioner>, Rhs>
Eigen::JacobiSVD<MatrixType, QRPreconditioner>::solve(const
Eigen::MatrixBase<OtherDerived>&) const [with Rhs =
Eigen::GeneralProduct<Eigen::Matrix<float, 36, 13>, Eigen::Matrix<double, -1, 1>, 4>;
_MatrixType = Eigen::Matrix<float, 36, 20>; int QRPreconditioner = 2]':
/usr/include/eigen3/Eigen/src/SVD/JacobiSVD.h:658:5: warning: control reaches end of
non-void function [-Wreturn-type]
make[2]: *** [src/CMakeFiles/spacebot_actuationKinematics.dir
/ActuationKinematics.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/spacebot_actuationKinematics.dir/all] Error 2
make: *** [all] Error 2