SVD computing different result in Matlab and OpenCV

后端 未结 3 899
遥遥无期
遥遥无期 2020-12-15 23:45

I wonder why there is sign difference in result for SVD computing in Matlab and OpenCV. I input the same matrix

          3.65E+06  -2.09E+06   0
 YY =    -         


        
相关标签:
3条回答
  • 2020-12-16 00:10

    Which version of OpenCV are you using?

    From http://code.opencv.org/issues/1498 it seems recent versions of OpenCV no longer use LAPACK to do SVD (as used by Matlab, I think). So the assumption that the same algorithm is being used might not be correct.

    Of course YY=USV'

    If you negate the first columns of U and V:

    U(:,1)=-U(:,1);
    V(:,1)=-V(:,1)
    

    You will find USV' still equals YY. This works for your particular case because YY is symmetric (YY=YY').

    0 讨论(0)
  • 2020-12-16 00:19

    The results of the SVD need not be unique. For example, I = UIV' for any unitary V = U. The example you give above in particular is rank deficient, so there is no reason to expect uniqueness.

    0 讨论(0)
  • 2020-12-16 00:20

    Singular Value Decomposition is only defined up to a sign; the signs of U and V are arbitrary, and if they are different between MATLAB and OpenCV that does not indicate a problem.

    0 讨论(0)
提交回复
热议问题