I have troubles to understand why arbitrary precision in Julia has to go through C code, like biglofats (that uses the mpfr library), and ArbNumerics (that uses the Arb library).
Although these are stunning packages and the underlying code is awesome, wouldnt an implementation of native julia bigfloat be better ? If no, why ? if yes, would it be very very hard to do ?
I think the “why” is it’s a lot of work. I’m sure people would be very thankful if you wrote a Julia-native
Yeah I would be thankful if someone wrote one too ! The question is rather would it be awfully slower than mpfr for reasons that I dont understand or is it still worth the shot
I think that most people suspect that a native julia
BigFloat would not be appreciably slower, but also likely wouldn’t be appreciably faster than existing implementations. However, there would be other potential advantages than speed, like better composability and introspectability.
I think it’s a worthy project, just not one that someone has tackled yet (as far as I’m aware). There are MANY projects worthy of tackling in julia right now.
One place where native
BigFloat would be faster is that the compiler would probably do a better job of re-using memory. That could lead to decent performance improvements.
Yeah, that’s very true. But we do have ways around that like MutableArithmetic.jl. Arguably, it’s be easier to make this package more general and more effortless to use than to reinvent BigFloat.
But I still think that one day a Julia user will reinvent BigFloat and it’ll be great.
It would be nice, and presumably “not too hard”, to “just” rewrite Arb in Julia.
It may be possible (or not) to get permission to do so with an MIT license.
However, as far as I understand / recall, Arb uses GMP or MPIR under the hood. Rewriting those seems like an even bigger undertaking.
And if I understood correctly, the mutability problem come straight from gmp/mpir/mpfr code ?
Yeah, kind of - GMP does a lot of things internally with memory and caching.
I’ve tried to reimplement BigInt in native julia about a year ago, but I couldn’t even get multiplication to work It’s certainly nontrivial and very hard to debug, since you can’t really visualize the big numbers it fails for properly… It did lead to a working property based testing framework with basic shrinking though, so it’s not a total loss.
That said, if it did work, I think it would be an amazing addition to the overall ecosystem