use SVD to find left inverse?

asked 2018-11-07 05:04:07 -0600

gino0717 gravatar image

updated 2018-11-07 05:05:36 -0600

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?

edit retag flag offensive close merge delete