Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-level mpn_get_str and mpn_set_str #1936

Open
albinahlback opened this issue Apr 29, 2024 · 2 comments
Open

Low-level mpn_get_str and mpn_set_str #1936

albinahlback opened this issue Apr 29, 2024 · 2 comments

Comments

@albinahlback
Copy link
Collaborator

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.

@fredrik-johansson
Copy link
Collaborator

We can certainly do better than the GMP basecases, by the way.

@albinahlback
Copy link
Collaborator Author

I think we should have three special cases:

  1. $b = 10$, i.e. decimal case
  2. $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.
  3. $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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants