py: Clean up and comment out unused functions in mpz.

This commit is contained in:
Damien George 2015-03-02 12:58:06 +00:00
parent 2af921fb51
commit a2e383820d
2 changed files with 20 additions and 30 deletions

View File

@ -803,6 +803,9 @@ bool mpz_is_zero(const mpz_t *z) {
return z->len == 0;
}
#if 0
these functions are unused
bool mpz_is_pos(const mpz_t *z) {
return z->len > 0 && z->neg == 0;
}
@ -818,6 +821,7 @@ bool mpz_is_odd(const mpz_t *z) {
bool mpz_is_even(const mpz_t *z) {
return z->len == 0 || (z->dig[0] & 1) == 0;
}
#endif
int mpz_cmp(const mpz_t *z1, const mpz_t *z2) {
// to catch comparison of -0 with +0
@ -921,6 +925,17 @@ mpz_t *mpz_pow(const mpz_t *lhs, const mpz_t *rhs) {
mpz_pow_inpl(z, lhs, rhs);
return z;
}
/* computes new integers in quo and rem such that:
quo * rhs + rem = lhs
0 <= rem < rhs
can have lhs, rhs the same
*/
void mpz_divmod(const mpz_t *lhs, const mpz_t *rhs, mpz_t **quo, mpz_t **rem) {
*quo = mpz_zero();
*rem = mpz_zero();
mpz_divmod_inpl(*quo, *rem, lhs, rhs);
}
#endif
/* computes dest = abs(z)
@ -1205,7 +1220,7 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
mpz_set_from_int(dest, 1);
while (n->len > 0) {
if (mpz_is_odd(n)) {
if ((n->dig[0] & 1) != 0) {
mpz_mul_inpl(dest, dest, x);
}
n->len = mpn_shr(n->dig, n->dig, n->len, 1);
@ -1219,6 +1234,9 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
mpz_free(n);
}
#if 0
these functions are unused
/* computes gcd(z1, z2)
based on Knuth's modified gcd algorithm (I think?)
gcd(z1, z2) >= 0
@ -1294,17 +1312,7 @@ mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2) {
rem->neg = 0;
return rem;
}
/* computes new integers in quo and rem such that:
quo * rhs + rem = lhs
0 <= rem < rhs
can have lhs, rhs the same
*/
void mpz_divmod(const mpz_t *lhs, const mpz_t *rhs, mpz_t **quo, mpz_t **rem) {
*quo = mpz_zero();
*rem = mpz_zero();
mpz_divmod_inpl(*quo, *rem, lhs, rhs);
}
#endif
/* computes new integers in quo and rem such that:
quo * rhs + rem = lhs

View File

@ -102,20 +102,8 @@ void mpz_set_from_float(mpz_t *z, mp_float_t src);
mp_uint_t mpz_set_from_str(mpz_t *z, const char *str, mp_uint_t len, bool neg, mp_uint_t base);
bool mpz_is_zero(const mpz_t *z);
bool mpz_is_pos(const mpz_t *z);
bool mpz_is_neg(const mpz_t *z);
bool mpz_is_odd(const mpz_t *z);
bool mpz_is_even(const mpz_t *z);
int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs);
mpz_t *mpz_abs(const mpz_t *z);
mpz_t *mpz_neg(const mpz_t *z);
mpz_t *mpz_add(const mpz_t *lhs, const mpz_t *rhs);
mpz_t *mpz_sub(const mpz_t *lhs, const mpz_t *rhs);
mpz_t *mpz_mul(const mpz_t *lhs, const mpz_t *rhs);
mpz_t *mpz_pow(const mpz_t *lhs, const mpz_t *rhs);
void mpz_abs_inpl(mpz_t *dest, const mpz_t *z);
void mpz_neg_inpl(mpz_t *dest, const mpz_t *z);
void mpz_not_inpl(mpz_t *dest, const mpz_t *z);
@ -128,13 +116,7 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs);
void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs);
void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs);
void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs);
mpz_t *mpz_gcd(const mpz_t *z1, const mpz_t *z2);
mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2);
void mpz_divmod(const mpz_t *lhs, const mpz_t *rhs, mpz_t **quo, mpz_t **rem);
void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs);
mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs);
mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs);
mp_int_t mpz_hash(const mpz_t *z);
bool mpz_as_int_checked(const mpz_t *z, mp_int_t *value);