Description
Starting from the discussion in #240 with @czurnieden, I thought a bit about the exposed API.
It might make sense to do a bit of an overhaul and make some functions private. In particular mp_digit
is exposed to often in the public API and it would be more useful to provide functions taking signed ints or longs. I consider mp_digit
to be more of an implementation detail.
mp_cmp_d
,mp_add_d
,mp_sub_d
,mp_div_d
,mp_mod_d
->mp_*_int
ormp_*_long
(not yet available)(DEPRECATED in open deprecate mp_expt_d and mp_n_root in favor of mp_expt and mp_root #304)mp_expt_d
->mp_expt_int
(DONE)mp_set
->mp_set_int
,mp_set_long
,mp_set_long_long
(already there)(DONE)mp_init_set
->mp_init_set_int
(already there)
Deprecation of the mp_*_d
functions could be done gracefully since they can be replaced by the more general mp_*_int
functions.
What could also be discussed is going to defined bit sizes since we include (DONE)stdint.h
and provide functions like mp_add_i32
instead of mp_add_int
/mp_add_long
. This would make the API platform independent. However this might be a bit of a too large deviation from how things are now.
Furthermore (KEEP)mp_set
is not needed anymore as soon as #221 #253 has been implemented. Right now mp_set
still makes sense since it is guaranteed to not allocate.
Then there are a few functions which seem to be internal and it might make sense to not expose them.
(KEEP since it pretty much harmless)mp_exch
(KEEP?)mp_rshd
,mp_lshd
(shifting by digits)(DEPRECATED in deprecate mp_prime_is_divisible and ltm_prime_tab #288)mp_prime_is_divisble
+ltm_prime_tab
(to special and dependent on MP_PRIME_SIZE, not generally useful?)(DEPRECATED in deprecate mp_n_root_ex and mp_expt_d_ex #294)mp_n_root_ex
(what is this fast parameter for?)(DEPRECATED in deprecate mp_n_root_ex and mp_expt_d_ex #294)mp_n_expt_d_ex
(what is this fast parameter for?)
Then there is the rand_digit function which is a remnant of before #236 and could be deprecated. (DEPRECATED)
Concerning the bit manipulation functions, there is mp_get_bit
but no mp_set_bit
. Either add mp_set_bit
or internalize mp_get_bit
as s_mp_get_bit
?
(DEPRECATED)mp_get_bit
,mp_set_bit
The one complement bitwise functions could also be internalized, since the two complement functions for positive ints are the equivalent.
(DEPRECATED)mp_xor
,mp_or
,mp_and
->mp_tc_*
(already there)(DEPRECATED)mp_tc_div_2d
->mp_bit_rsh