arb
arb copied to clipboard
lazy conversion from/to to mpfr
Is there a very low-overhead way to convert (or rather move) limbs (and also take care of other members of the wrapping struct) from arf_t to/from mpfr_t ?
It depends on what you need to do. It is possible to set an mpfr_t to a shallow read-only copy of an arf_t: see https://github.com/fredrik-johansson/arb/blob/master/arf/sqrt.c for example.
The reverse operation is possible too but one has to normalize by taking out the zero limbs and taking care of the separate n <= 2 limbs case.
One has to be careful about special values and huge exponents.
Shallow copies for writing would not be safe.
I understand that sharing the limbs from both interfaces is not really possible, but it would be great to have a standard API call to adapt the limbs from one to the other wrapper. I will try to do it myself at first (and submit if I succeed). Is there an error flag on the arf_t size to warn about subnormal numbers ?