Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in SVD? #508

Open
michael-bauer-horsch opened this issue Feb 8, 2023 · 3 comments
Open

Bug in SVD? #508

michael-bauer-horsch opened this issue Feb 8, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@michael-bauer-horsch
Copy link

I have some doubts about the correctness of the implementation of Singular Value Decomposition.

Take f.e. this input matrix/tensor:
{{6,3,-3},{-3,3,6},{-3,-6,-3}}

WolframAlpha and numpy will calculate the following singular values: 9, 9, 0,
whereas kmath will differ in the last singular value by giving 8.2206 with default epsilon.

Also, values in U and V are different - WolframAlpha is able to come up with the exact values it seems.

I don't understand the math. From what I've researched, my input matrix might not be the best example by allowing for some freedom in U, S, V.

Still, kmath's result differs from the results numpy and Wolfram are giving which makes me think that something is suboptimal on kmath side.
Also, the rigid pose estimation I'm using SVD for is failing with kmath while it is working fine with Python/numpy
(while using the exact same afore-mentioned input matrix).

Let me know if I should prepare a MWE.

@SPC-code
Copy link
Contributor

@grinisrit Could you check that?

@SPC-code SPC-code added the bug Something isn't working label Feb 14, 2023
@r6wy2
Copy link

r6wy2 commented Apr 30, 2023

commons-math3 gives the correct solution.
As it is included as dependency why not also use it for solving svd?

@SPC-code
Copy link
Contributor

@r6wy2 @michael-bauer-horsch sorry for the late reply. Commons math is a dependency only form KMath-commons it works only on JVM while KMath. You can use it as well as KMath-ejml if you need only JVM support. Both variants are compatible with the rest of KMath algebras.

@grinisrit could you please check if there is a bug in the algorithm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants