OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 07 Nov 2018 05:04:07 -0600use SVD to find left inverse?http://answers.opencv.org/question/202657/use-svd-to-find-left-inverse/I'm trying some basic linear algebra function. I want to solve a singular matrix which is not easy to get inverse matrix.
for example, I have
> A = [-1, 0, 0, 0, 1, 0, 0, 0; 0, -1,
> 0, 0, 0, 1, 0, 0]
since is non-inevitable, we should use SVD to get the inverse.
I try this code (skiped the steps to assign value to A)
Mat inverse= (A).inv(DECOMP_SVD);
cout << "A * inverse = " << A*inverse << endl;
cout << "inverse * A = " << inverse*A << endl;
and the outputs would be
A * inverse =
[0.5, 0, 0, 0, -0.5, 0, 0, 0;
0, 0.5, 0, 0, 0, -0.5, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
-0.5, 0, 0, 0, 0.5, 0, 0, 0;
0, -0.5, 0, 0, 0, 0.5, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0]
(bad)
inverse * A =
[1, 0;
0, 1]
(good)
so the left inverse not equal to the right inverse. However in the function I can just get the right one. How should I get the left one?Wed, 07 Nov 2018 05:04:07 -0600http://answers.opencv.org/question/202657/use-svd-to-find-left-inverse/