brainexcerpts / 3x3_polar_decomposition

Polar decomposition of a 3x3 matrix
BSD 2-Clause "Simplified" License
12 stars 2 forks source link

SVD 3x3 #1

Open mu578 opened 4 years ago

mu578 commented 4 years ago

Hello, your approach would not handle extreme cases + do not change v sign according to its determinant + neither using eigen-values of ATA to compute your singular-values; instead; rotate later your basis; a faster, efficient and more stable algorithm in a such case:

SVD3X3(A):
   ata  = A'*A
   V    = EIG3X3(ata)
   av   = A*V
   U, S = RMGS3X3(av) or QRGIVENS
   // change sign of each V column according to its corresponding S such as S >= 0

Have a good day.

brainexcerpts commented 4 years ago

Thanks for the feedback, I have a few questions: Is there any reference publication of your algorithm? Can you point to any reference implementation? What is a typical fail case for my implementation?

mu578 commented 4 years ago

Hello,

// is there any reference publication of your algorithm? 
many however none from myself.
// Can you point to any reference implementation?
no.
// What is a typical fail case for my implementation?
0 0 0
0 3 0
0 0 2

1 2 3
4 5 6
7 8 9

and so on.

+ I ~= U'U is not satisfied, hence orthogonality is not achieved.
brainexcerpts commented 4 years ago

I see, thank you for clarifying the fail case. Maybe I should switch to A. McAdams & Al SVD implementation in the future http://pages.cs.wisc.edu/~sifakis/project_pages/svd.html

mu578 commented 4 years ago

yes; or not; as it's very branded x86 CPUs based; + would be interesting to compare to a compiler that handles vectorization, if any gain at all by going thru a brute-force coding approach; anyhow, here the most important goal is first to achieve numerical-stability and algorithm accuracy.

This following code (1) is synthesizable and have been successfully laid out on different IPs; also been stressed out on various bare-metal low-power dev boards; can be still optimized.

1- https://github.com/moe123/macadam/blob/master/macadam/details/numa/mc_svd3x3.h