aboutsummaryrefslogtreecommitdiff
path: root/py/mpz.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-03-02 12:58:06 +0000
committerDamien George <damien.p.george@gmail.com>2015-03-02 12:58:06 +0000
commita2e383820d28dcf2167ae67089346ef5775cb669 (patch)
tree730ed6d64953ed27121e26024dcce43a2ecd5ebf /py/mpz.c
parent2af921fb51be3d380058d93f71ad0f41c8d5c160 (diff)
py: Clean up and comment out unused functions in mpz.
Diffstat (limited to 'py/mpz.c')
-rw-r--r--py/mpz.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/py/mpz.c b/py/mpz.c
index a056a6e8a..dbad14148 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -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