|Keep It Simple, Stupid|
Re^4: Algorithm for cancelling common factors between two lists of multiplicandsby BrowserUk (Pope)
|on Aug 12, 2005 at 22:32 UTC||Need Help??|
With that insight, I removed all the factoring and cancelling code and came up with this version:
Which, if you can live with the lower accuracy, for the (5 0 1 4) and (989 9400 43300 2400) datasets, compares favourably with my (rough) timings of tmoertel's compiled Haskell code, the Math::Pari version and blows the M::BF version into dust.
Where it gets really interesting is when you look at bigger numbers. I tried it with (1e5 2e5 2e5 1e5) and it took 81 seconds.
Math::Pari can't handle numbers this big, and the Haskell version ran for roughly an hour before I abandoned it.
It makes me think that maybe a Math::Big library based around the idea of the scaled math I use in sProduct() might be useful for large number work that doesn't require absolute precision?
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.