jwmerrill/Pnums.jl

Pnum32

eschnett opened this issue · 1 comments

Thanks for your presentation today -- very cool.

I managed to easily extend your package to provide a type Pnum32 as well. I couldn't really expand the exponent range (that doesn't work with Rational), and initializing the exacts array takes a long time. Apart from this, the new type works just fine and is quite efficient:

julia> @time findroots(x->x^2-2, pb32"everything") |> Pnums.print_decimal
(-1.4142135977745056, -1.4142135381698608)
(1.4142135381698608, 1.4142135977745056)
  0.019251 seconds (285.87 k allocations: 4.816 MB)

If I calculate correctly, this type has even more precision than Float32.

Getting around the exacts limitation would probably require two steps:

  • Don't store all values; instead, use a function that calculates them just-in time.
  • Don't use Rational to represent them; instead, represent them by Rational with an exponent. That will require either handling rounding during addition, or using BigInt if necessary.

That's awesome. I'm glad you were able to dive in and extend things reasonably easily.

I think avoiding actually storing the exacts is a good idea, as long as you've chosen then in a way that it's reasonably easy to do binary search on their ordered values.

Not sure what to do about extending the exponent.