-
Notifications
You must be signed in to change notification settings - Fork 4
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
Result contains NaN for some matrices #5
Comments
There are some divided by zero in implementation I can provide fix @danilosalvati if you want. |
Sorry @hasanbalci I completely forgot to answer your issue... At a first look it seem your bug is caused from eps parameter... I tried with runkit your first example with const svdJs = require("svd-js")
const a = [[-896, -896], [-19, -19]]
const { u, v, q } = svdJs.SVD(a, true, true, 1e-15)
console.log(u)
console.log(v)
console.log(q)
// output:
// [[0.02120059107367143, -0.9997752422110318], [-0.9997752422110316,0.021200591073671428]]
// [[-0.7071067811865475, 0.7071067811865476], [0.7071067811865475, 0.7071067811865474]]
// [0, 1267.4202144513872] @DamianCz Where did you found those divided by zero in the implementation? Anyway PRs are always welcome 😄 |
@danilosalvati It seems that adding eps parameter as 1e-15 is working in my first example but not in the second one. |
@danilosalvati it is safe to check all divided places . I will add PR when I will find time |
Hi, DamianCz, did you fix "ZeroDivisionError: float division by zero"? |
@pygabc1 I have added function and replace all usage of / with this function. Will add PR this week.
|
Did this ever get fixed?
The expected output for I tried the solution that replaces all the divisions with the function shown by @DamianCz. Yes, the NaN values are gone, but |
I ran into this too. Another example:
|
I am considering to use your implementation, but during testing I realized that the result (especially u and q) of some matrices contains NaN values.
Some examples are:
input: [[-896, -896], [-19, -19]]
output:
u = [[NaN, NaN], [NaN, NaN]]
q = [0, NaN]
v = [[0.7071067811865476, -0.7071067811865475], [-0.7071067811865474, -0.7071067811865475]]
input: [[0, 0],[-1560.116, -2789.99]]
output:
u = [[NaN, NaN], [NaN, NaN]]
q = [0, NaN]
v = [[0.8728097060016351, -0.48806066949646665], [-0.48806066949646654, -0.8728097060016349]]
Thanks!
The text was updated successfully, but these errors were encountered: