ericjang / svd3

Fast singular value decomposition, diagonalization, QR decomposition of 3x3 matrices.
MIT License
149 stars 19 forks source link

The results not accurate at all #3

Closed datainfer closed 7 years ago

datainfer commented 9 years ago

(1) U and V are not orthonormal. U * U' != I and V * V' != I (2) S is not diagonal. (3) U * S * V' != A.

With unacceptable error range, it cannot do anything serious. It even cannot say a good approximation.

Please past a warning on the main page.

Test case:

A

A =

0.8147    0.9134    0.2785
0.9058    0.6324    0.5469
0.1270    0.0975    0.9575

[ U3, S3, V3 ] = imgreg.svd3( A )

U3 =

0.6626   -0.4088    0.6242
0.6736   -0.0352   -0.7354
0.3245    0.9096    0.2525

S3 =

1.7961
0.8341

-0.1794

V3 =

0.6661   -0.2963    0.6695
0.5670   -0.3616   -0.7289
0.4632    0.8798   -0.0638

U3 * U3'

ans =

0.9958    0.0017    0.0008
0.0017    0.9959    0.0008
0.0008    0.0008    0.9965

V3 * V3'

ans =

0.9797 -0.0031 0.0051 -0.0031 0.9835 -0.0091 0.0051 -0.0091 0.9927

U3 * diag( S3 ) * V3' - A

ans =

0.0041 -0.0337 -0.0202 -0.0028 -0.0319 -0.0208 0.0061 -0.0084 -0.0171

Wulonghua commented 7 years ago

The CUDA version still has bug that doesn't sort the singular values properly. But it's easy to fix.

ericjang commented 7 years ago

Fixed it. thanks