flint
flint copied to clipboard
Low-level `mpn_get_str` and `mpn_set_str`
Arguably, we should have a low-level mpn_get_str and mpn_set_str that utilizes the Fredrik's algorithms in fmpz_get_str and fmpz_set_str.
Preferably, this one should be declared on the formats
mp_size_t mpn_set_str(mp_ptr rp, const char * ip, size_t strlen, int base);
size_t mpn_get_str(char * rp, mp_srcptr up, mp_size_t un, int base);
and should assume that the input is correct. For high-level functions, mpn_set_str could be coupled with some very simple function that verifies that const char * ip is on the right format.
We can certainly do better than the GMP basecases, by the way.
I think we should have three special cases:
- $b = 10$, i.e. decimal case
- $b = 2$, i.e. binary case (nice to have fast bitstring representation, but perhaps no need to have a multi-threaded version). Useful for debugging.
- $b = 16$, i.e. hexadecimal. Also useful for debugging, and is more compact than decimal case (and faster conversion as well).
The rest could just be handled by GMP.