arb icon indicating copy to clipboard operation
arb copied to clipboard

lazy conversion from/to to mpfr

Open chacha21 opened this issue 6 years ago • 2 comments

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 ?

chacha21 avatar Feb 03 '19 09:02 chacha21

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.

fredrik-johansson avatar Feb 03 '19 10:02 fredrik-johansson

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 ?

chacha21 avatar Feb 03 '19 10:02 chacha21