dmalhotra / pvfmm

A parallel kernel-independent FMM library for particle and volume potentials
http://pvfmm.org
GNU Lesser General Public License v3.0
51 stars 28 forks source link

SVD loops forever in certain cases #5

Closed translunar closed 7 years ago

translunar commented 7 years ago

I'm not sure how to fix it, but your SVD algorithm isn't incrementing k0 in some cases — it then enters an infinite loop.

First found it here: http://stackoverflow.com/questions/3856072/single-value-decomposition-implementation-c/25291714#25291714

dmalhotra commented 7 years ago

Thanks for reporting this issue. Can you provide a test case that I can use to debug?

translunar commented 7 years ago

Yes, I think so. Upon further examination, looks like it's happening with rank deficient matrices. Try this one:

{{267.21359999999999, -267.21359999999999, -230.9624}, {-4383.1704, 4383.1704, -4383.1704}, {0, 0, 0}}

translunar commented 7 years ago

I also notice you have some divisions by 2 instead of 2.0, which will cause truncation (separate issue).

dmalhotra commented 7 years ago

I don't believe dividing a float or double by an integer will cause truncation.

dmalhotra commented 7 years ago

30759297f670fcdec61b3404b8b6e8f762a6a979 fixes this issue.

translunar commented 7 years ago

@dmalhotra Huh, wow. You're totally right! I've been believing something that was totally wrong for the greater part of fifteen years.