Re: Bignums, object grind, and garbage collection
Lew wrote:
John Ersatznom wrote:
> ... several salient points ...
You make good points. I am curious how well the JVM would keep up with
immutable classes in an app like yours, and how much difference it
really makes to use mutable instances.
Since the Sun classes evidently use a slow algorithm you are thrown into
the world of third parties or roll-yer-own anyway.
I'm currently leaning toward rolling my own wrapper classes, but using
the JScience LargeInteger under the hood with a PoolContext. I had a
look at the LargeInteger source code, and it uses normal multiplies up
to a point and then Karatsuba multiplies, which looks efficient. OTOH,
the Real class in JScience does pretty much every operation twice to
maintain a scientifically-controlled error bound. For some numerical
stuff this would be important, but for some of my plans I need speed and
behavior similar to a normal float or double that happens to have a huge
mantissa, which means wrapping LargeInteger with a power-of-2 exponent
and doing everything only once. :)
Eventually I want an FFT implementation to throw at floating-point
calculations reaching the several thousands of bits, though, as well,
but I'll cross that one when I come to it.
One thing I'll probably be doing is dropping the LSBs off the more
accurate operand in adds and subtracts. Their effect disappears in the
noise anyway.