summaryrefslogtreecommitdiff
path: root/tests/refmpz.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-09-08 02:40:35 +0200
committerKevin Ryde <user42@zip.com.au>2001-09-08 02:40:35 +0200
commit58c56ba1da82d2a59f01b27a4e5c593925befa9a (patch)
tree288c9b3788db6de325aa9fa24b7e7ed9a8735527 /tests/refmpz.c
parent69f3cd11e8cfd0fc5839099166aa983939c3de0f (diff)
downloadgmp-58c56ba1da82d2a59f01b27a4e5c593925befa9a.tar.gz
* tests/refmpz.c, tests/tests.h (refmpz_hamdist): New function.
Diffstat (limited to 'tests/refmpz.c')
-rw-r--r--tests/refmpz.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/tests/refmpz.c b/tests/refmpz.c
index 58ad67371..8dae09eff 100644
--- a/tests/refmpz.c
+++ b/tests/refmpz.c
@@ -1,6 +1,5 @@
-/* Reference mpz functions */
+/* Reference mpz functions.
-/*
Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -18,8 +17,7 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-MA 02111-1307, USA.
-*/
+MA 02111-1307, USA. */
/* always do assertion checking */
#define WANT_ASSERT 1
@@ -35,6 +33,41 @@ MA 02111-1307, USA.
#define TRACE(x)
+unsigned long
+refmpz_hamdist (mpz_srcptr x, mpz_srcptr y)
+{
+ mp_size_t tsize;
+ mp_ptr xp, yp;
+ unsigned long ret;
+
+ if ((SIZ(x) < 0 && SIZ(y) >= 0)
+ || (SIZ(y) < 0 && SIZ(x) >= 0))
+ return ULONG_MAX;
+
+ tsize = MAX (ABSIZ(x), ABSIZ(y));
+
+ xp = refmpn_malloc_limbs (tsize);
+ refmpn_zero (xp, tsize);
+ refmpn_copy (xp, PTR(x), ABSIZ(x));
+
+ yp = refmpn_malloc_limbs (tsize);
+ refmpn_zero (yp, tsize);
+ refmpn_copy (yp, PTR(y), ABSIZ(y));
+
+ if (SIZ(x) < 0)
+ refmpn_neg_n (xp, xp, tsize);
+
+ if (SIZ(x) < 0)
+ refmpn_neg_n (yp, yp, tsize);
+
+ ret = refmpn_hamdist (xp, yp, tsize);
+
+ free (xp);
+ free (yp);
+ return ret;
+}
+
+
/* (0/b), with mpz b; is 1 if b=+/-1, 0 otherwise */
#define JACOBI_0Z(b) JACOBI_0LS (PTR(b)[0], SIZ(b))
@@ -45,7 +78,6 @@ MA 02111-1307, USA.
is (-1/b) if a<0, or +1 if a>=0 */
#define JACOBI_ASGN_ZZU_BIT1(a, b) JACOBI_ASGN_SU_BIT1 (SIZ(a), PTR(b)[0])
-
int
refmpz_kronecker (mpz_srcptr a_orig, mpz_srcptr b_orig)
{