ericjang/svd3

Numerical Error due to incorrect Givens Approximation?

Closed this issue · 2 comments

For anyone reading this code and trying to reimplement it (I was reimplementing it in Rust), I found that there were significant numerical errors (as referenced by other issues), and increasing the number of jacobi iterations made the error worse. While I didn't dig too deeply into the rest of the code, I noticed that the approximate givens quaternion differed significantly from the original paper. To test the differences, I basically copied the paper's pseudocode into my implementation, and found that it resolved numerical errors.

For anyone using this repo in the future, hopefully this will be helpful, and not sure if it affects this repo's correctness.

There's also a notebook containing derivations for their math shortcuts, but I don't use jupyter, and there's not an easy way on github to view it.

After further testing, I'm less confident that this is correct. I accidentally swapped the givens angle with the givens quaternion computation, and found for an identity matrix that it was correct, but all other matrices were wrong.

Actually, I did find that this was broken. Specifically, in the case when (a11-a22) = 0 and a12 = 0. This may lead to incorrect quaternion rotations. Adding a manual that they're both near 0 and returning [1., 0.] may make it more robust.