summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-10-12 05:02:56 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2007-10-12 05:02:56 (GMT)
commit57cf6151647252e0eb2a05fa78f67e3601c7d4e9 (patch)
treee63e6fe3f1433647d4923e4d9db641560724ec7c
parent3a01eee61c1ada7fcc83ae0c0cd5f8f25b8d5001 (diff)
downloadpbn-57cf6151647252e0eb2a05fa78f67e3601c7d4e9.zip
pbn-57cf6151647252e0eb2a05fa78f67e3601c7d4e9.tar.gz
pbn-57cf6151647252e0eb2a05fa78f67e3601c7d4e9.tar.bz2
pbn-57cf6151647252e0eb2a05fa78f67e3601c7d4e9.tar.xz
Change name from mpn to "pbn" (Peter's BigNum library)
-rw-r--r--Makefile2
-rw-r--r--mpn.h78
-rw-r--r--pbn.h78
-rw-r--r--pbn_add.c (renamed from mpn_add.c)46
-rw-r--r--pbn_cmp.c (renamed from mpn_cmp.c)8
-rw-r--r--pbn_div.c37
-rw-r--r--pbn_dump.c (renamed from mpn_dump.c)16
-rw-r--r--pbn_init.c (renamed from mpn_init.c)90
-rw-r--r--pbn_mul.c (renamed from mpn_mul.c)33
-rw-r--r--pbnint.h (renamed from mpnint.h)10
-rw-r--r--test.c28
11 files changed, 233 insertions, 193 deletions
diff --git a/Makefile b/Makefile
index af7d553..36bf09a 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CC = gcc
CFLAGS = -g -D_FORTIFY_SOURCE=2 -W -Wall
LDFLAGS =
-LIBOBJ = mpn_add.o mpn_cmp.o mpn_dump.o mpn_init.o mpn_mul.o
+LIBOBJ = pbn_add.o pbn_cmp.o pbn_dump.o pbn_init.o pbn_mul.o
TESTS = test
diff --git a/mpn.h b/mpn.h
deleted file mode 100644
index 98f4883..0000000
--- a/mpn.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2007 H. Peter Anvin - All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, Inc.,
- * 59 Temple Place Ste 330, Boston MA 02111-1307, USA; version 2.1,
- * incorporated herein by reference.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * mpn.h
- *
- * Simple multi-precision signed integer library
- */
-
-#ifndef MPN_H
-#define MPN_H
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <inttypes.h>
-
-/* Configurables */
-
-#define MPN_ATOM_BITS 32
-#define MPN_ATOM_xFMT "08"PRIx32
-typedef uint32_t mpn_atom_t;
-typedef uint64_t mpn_2atom_t;
-typedef int32_t mpn_satom_t;
-typedef int64_t mpn_2satom_t;
-
-struct mpn {
- int ref;
- int len;
- int bits;
- int minus;
- mpn_atom_t num[1];
-};
-
-
-#define _mpn_malloc(x) malloc(x)
-#define _mpn_zalloc(x) calloc(x,1)
-#define _mpn_free(x) free(x)
-#define _mpn_realloc(x,y) realloc(x,y)
-
-#define mpn_ref(x) ((x)->ref++, (x))
-
-#if defined(__GNUC__) && !defined(MPN_INIT)
-extern inline void mpn_free(struct mpn *__mpn)
-{
- if (! --__mpn->ref)
- _mpn_free(__mpn);
-}
-#else
-void mpn_free(struct mpn *);
-#endif
-struct mpn *mpn_addsub(struct mpn *, struct mpn *, int issub);
-#define mpn_add(x,y) mpn_addsub(x,y,0)
-#define mpn_sub(x,y) mpn_addsub(x,y,1)
-int mpn_cmp(struct mpn *, struct mpn *);
-struct mpn *mpn_mul(struct mpn *, struct mpn *);
-struct mpn *mpn_shr(struct mpn *, int);
-struct mpn *mpn_shl(struct mpn *, int);
-void mpn_dump(FILE *, struct mpn *);
-struct mpn *mpn_int(mpn_satom_t);
-struct mpn *mpn_new(int);
-struct mpn *mpn_dup(const struct mpn *);
-struct mpn *mpn_dupx(const struct mpn *, int);
-struct mpn *mpn_cow(struct mpn *, int);
-
-/* Internal functions */
-void _mpn_adjust_bits(struct mpn *mpn);
-
-#endif /* MPN_H */
diff --git a/pbn.h b/pbn.h
new file mode 100644
index 0000000..1dae30b
--- /dev/null
+++ b/pbn.h
@@ -0,0 +1,78 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2007 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, Inc.,
+ * 59 Temple Place Ste 330, Boston MA 02111-1307, USA; version 2.1,
+ * incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * pbn.h
+ *
+ * Simple multi-precision signed integer library
+ */
+
+#ifndef PBN_H
+#define PBN_H
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+
+/* Configurables */
+
+#define PBN_ATOM_BITS 32
+#define PBN_ATOM_xFMT "08"PRIx32
+typedef uint32_t pbn_atom_t;
+typedef uint64_t pbn_2atom_t;
+typedef int32_t pbn_satom_t;
+typedef int64_t pbn_2satom_t;
+
+struct pbn {
+ int ref;
+ int len;
+ int bits;
+ int minus;
+ pbn_atom_t num[1];
+};
+
+
+#define _pbn_malloc(x) malloc(x)
+#define _pbn_zalloc(x) calloc(x,1)
+#define _pbn_free(x) free(x)
+#define _pbn_realloc(x,y) realloc(x,y)
+
+#define pbn_ref(x) ((x)->ref++, (x))
+
+#if defined(__GNUC__) && !defined(PBN_INIT)
+extern inline void pbn_free(struct pbn *__pbn)
+{
+ if (! --__pbn->ref)
+ _pbn_free(__pbn);
+}
+#else
+void pbn_free(struct pbn *);
+#endif
+struct pbn *pbn_addsub(struct pbn *, struct pbn *, int issub);
+#define pbn_add(x,y) pbn_addsub(x,y,0)
+#define pbn_sub(x,y) pbn_addsub(x,y,1)
+int pbn_cmp(struct pbn *, struct pbn *);
+struct pbn *pbn_mul(struct pbn *, struct pbn *);
+struct pbn *pbn_shr(struct pbn *, int);
+struct pbn *pbn_shl(struct pbn *, int);
+void pbn_dump(FILE *, struct pbn *);
+struct pbn *pbn_int(pbn_satom_t);
+struct pbn *pbn_new(int);
+struct pbn *pbn_dup(const struct pbn *);
+struct pbn *pbn_dupx(const struct pbn *, int);
+struct pbn *pbn_cow(struct pbn *, int);
+
+/* Internal functions */
+void _pbn_adjust_bits(struct pbn *pbn);
+
+#endif /* PBN_H */
diff --git a/mpn_add.c b/pbn_add.c
index d5c732a..25372f0 100644
--- a/mpn_add.c
+++ b/pbn_add.c
@@ -11,39 +11,39 @@
* ----------------------------------------------------------------------- */
/*
- * mpn_add.c
+ * pbn_add.c
*/
-#include "mpnint.h"
+#include "pbnint.h"
-struct mpn *mpn_addsub(struct mpn *s1, struct mpn *s2, int issub)
+struct pbn *pbn_addsub(struct pbn *s1, struct pbn *s2, int issub)
{
int bits, len;
- struct mpn *d;
+ struct pbn *d;
int i;
int s1minus = s1->minus;
int s2minus = s2->minus ^ issub;
int dminus;
bits = s2->bits > s1->bits ? s2->bits+1 : s1->bits+1;
- len = (bits+MPN_ATOM_BITS-1)/MPN_ATOM_BITS;
+ len = (bits+PBN_ATOM_BITS-1)/PBN_ATOM_BITS;
if (s1 == s2) {
- s1 = mpn_dupx(s1, len);
- mpn_free(s2); /* Drop one reference */
+ s1 = pbn_dupx(s1, len);
+ pbn_free(s2); /* Drop one reference */
}
if (s1minus == s2minus) {
- mpn_2atom_t c;
+ pbn_2atom_t c;
/* Sign is the same, addition */
if (s1->ref > s2->ref) {
- struct mpn *t = s1;
+ struct pbn *t = s1;
s1 = s2;
s2 = t;
}
- d = mpn_cow(s1, len);
+ d = pbn_cow(s1, len);
d->bits = bits;
c = 0;
@@ -53,36 +53,36 @@ struct mpn *mpn_addsub(struct mpn *s1, struct mpn *s2, int issub)
c += s2->num[i];
d->num[i] = c;
- c >>= MPN_ATOM_BITS;
+ c >>= PBN_ATOM_BITS;
}
- mpn_free(s2);
+ pbn_free(s2);
/* d->minus already copied from s1->minus */
} else {
- mpn_2satom_t c; /* Relies on 2's complement with
+ pbn_2satom_t c; /* Relies on 2's complement with
proper right arithmetic shift... */
/* We know the sign is different */
dminus = 0;
if (s2minus) {
- struct mpn *t = s1;
+ struct pbn *t = s1;
s1 = s2;
s2 = t;
dminus = !dminus;
}
/* Now s1 is the addend and s2 is the subtrahend */
- if (mpn_cmp(s1, s2) < 0) {
+ if (pbn_cmp(s1, s2) < 0) {
/* addend is smaller than subtrahend, reverse and
invert minus */
- struct mpn *t = s1;
+ struct pbn *t = s1;
s1 = s2;
s2 = t;
dminus = !dminus;
}
if (s1->ref > s2->ref) {
- d = mpn_cow(s2, len);
+ d = pbn_cow(s2, len);
c = 0;
for (i = 0; i < len; i++) {
@@ -91,11 +91,11 @@ struct mpn *mpn_addsub(struct mpn *s1, struct mpn *s2, int issub)
c += s1->num[i];
d->num[i] = c;
- c >>= MPN_ATOM_BITS;
+ c >>= PBN_ATOM_BITS;
}
- mpn_free(s1);
+ pbn_free(s1);
} else {
- d = mpn_cow(s1, len);
+ d = pbn_cow(s1, len);
c = 0;
for (i = 0; i < len; i++) {
@@ -104,15 +104,15 @@ struct mpn *mpn_addsub(struct mpn *s1, struct mpn *s2, int issub)
c -= s2->num[i];
d->num[i] = c;
- c >>= MPN_ATOM_BITS;
+ c >>= PBN_ATOM_BITS;
}
- mpn_free(s2);
+ pbn_free(s2);
}
d->minus = dminus;
}
- _mpn_adjust_bits(d);
+ _pbn_adjust_bits(d);
return d;
}
diff --git a/mpn_cmp.c b/pbn_cmp.c
index 59ffcf4..1a2518d 100644
--- a/mpn_cmp.c
+++ b/pbn_cmp.c
@@ -11,12 +11,12 @@
* ----------------------------------------------------------------------- */
/*
- * mpn_cmp.c
+ * pbn_cmp.c
*/
-#include "mpnint.h"
+#include "pbnint.h"
-int mpn_cmp(struct mpn *s1, struct mpn *s2)
+int pbn_cmp(struct pbn *s1, struct pbn *s2)
{
int lt = s1->minus ? 1 : -1;
int gt = -lt;
@@ -30,7 +30,7 @@ int mpn_cmp(struct mpn *s1, struct mpn *s2)
else if (s1->bits > s2->bits)
return gt;
- i = (s1->bits+MPN_ATOM_BITS-1)/MPN_ATOM_BITS;
+ i = (s1->bits+PBN_ATOM_BITS-1)/PBN_ATOM_BITS;
while (i >= 0) {
if (s1->num[i] > s2->num[i])
return gt;
diff --git a/pbn_div.c b/pbn_div.c
new file mode 100644
index 0000000..6c169ac
--- /dev/null
+++ b/pbn_div.c
@@ -0,0 +1,37 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2007 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, Inc.,
+ * 59 Temple Place Ste 330, Boston MA 02111-1307, USA; version 2.1,
+ * incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * pbn_div.c
+ */
+
+/* quotient, remainder, numerator, denominator
+
+ The sign on the outputs = sign(numerator) XOR sign(denominator)
+
+ Returns -1 on error (divide by zero) and frees the inputs */
+
+#include "pbn.h"
+
+int pbn_div(struct pbn **q, struct pbn **r, struct pbn *n, struct pbn *d)
+{
+ if (d->bits == 0) {
+ pbn_free(n);
+ pbn_free(d);
+ return -1; /* Division by zero */
+ }
+
+
+
+
+}
+
diff --git a/mpn_dump.c b/pbn_dump.c
index bffb165..5dbcde1 100644
--- a/mpn_dump.c
+++ b/pbn_dump.c
@@ -11,25 +11,25 @@
* ----------------------------------------------------------------------- */
/*
- * mpn_dump.c
+ * pbn_dump.c
*
- * Output an MPN in hexadecimal form, mainly intended for debugging
+ * Output an PBN in hexadecimal form, mainly intended for debugging
*/
#include <stdio.h>
-#include "mpnint.h"
+#include "pbnint.h"
-void mpn_dump(FILE *f, struct mpn *mpn)
+void pbn_dump(FILE *f, struct pbn *pbn)
{
int i;
- putc(mpn->minus ? '-' : '+', f);
+ putc(pbn->minus ? '-' : '+', f);
- for (i = mpn->len-1; i >= 0; i--) {
- fprintf(f, "%" MPN_ATOM_xFMT, mpn->num[i]);
+ for (i = pbn->len-1; i >= 0; i--) {
+ fprintf(f, "%" PBN_ATOM_xFMT, pbn->num[i]);
if (i)
putc('_', f);
}
- mpn_free(mpn);
+ pbn_free(pbn);
}
diff --git a/mpn_init.c b/pbn_init.c
index 2770b9f..53edb87 100644
--- a/mpn_init.c
+++ b/pbn_init.c
@@ -11,42 +11,42 @@
* ----------------------------------------------------------------------- */
/*
- * mpn_int.c
+ * pbn_int.c
*/
-#define MPN_INIT 1
+#define PBN_INIT 1
#include <string.h>
-#include "mpnint.h"
+#include "pbnint.h"
-struct mpn *mpn_new(int len)
+struct pbn *pbn_new(int len)
{
- struct mpn *mpn;
+ struct pbn *pbn;
- mpn = _mpn_zalloc(sizeof(struct mpn)+(len-1)*sizeof(mpn_atom_t));
- if (!mpn)
+ pbn = _pbn_zalloc(sizeof(struct pbn)+(len-1)*sizeof(pbn_atom_t));
+ if (!pbn)
return NULL;
- mpn->ref = 1;
- mpn->len = len;
+ pbn->ref = 1;
+ pbn->len = len;
- return mpn;
+ return pbn;
}
-void mpn_free(struct mpn *mpn)
+void pbn_free(struct pbn *pbn)
{
- if (! --mpn->ref)
- _mpn_free(mpn);
+ if (! --pbn->ref)
+ _pbn_free(pbn);
}
-#if MPN_ATOM_BITS != 32 && MPN_ATOM_BITS != 64
-# error "Fix mpn_ilog2p1 for new MPN_ATOM_BITS size"
+#if PBN_ATOM_BITS != 32 && PBN_ATOM_BITS != 64
+# error "Fix pbn_ilog2p1 for new PBN_ATOM_BITS size"
#endif
-static int mpn_ilog2p1(mpn_atom_t v)
+static int pbn_ilog2p1(pbn_atom_t v)
{
int p = 1;
-#if MPN_ATOM_BITS >= 64
+#if PBN_ATOM_BITS >= 64
if (v & 0xffffffff00000000) {
p += 32;
v >>= 32;
@@ -77,29 +77,29 @@ static int mpn_ilog2p1(mpn_atom_t v)
return p;
}
-struct mpn *mpn_int(mpn_satom_t v)
+struct pbn *pbn_int(pbn_satom_t v)
{
- struct mpn *mpn = mpn_new(1);
- if (!mpn)
+ struct pbn *pbn = pbn_new(1);
+ if (!pbn)
return NULL;
if (v < 0) {
v = -v;
- mpn->minus = 1;
+ pbn->minus = 1;
} else {
- mpn->minus = 0;
+ pbn->minus = 0;
}
- mpn->num[0] = v;
- mpn->bits = mpn_ilog2p1(v);
- return mpn;
+ pbn->num[0] = v;
+ pbn->bits = pbn_ilog2p1(v);
+ return pbn;
}
/* Produce a duplicate */
-struct mpn *mpn_dup(const struct mpn *src)
+struct pbn *pbn_dup(const struct pbn *src)
{
- int bytes = sizeof(struct mpn)+(src->len-1)*sizeof(mpn_atom_t);
- struct mpn *dst = _mpn_malloc(bytes);
+ int bytes = sizeof(struct pbn)+(src->len-1)*sizeof(pbn_atom_t);
+ struct pbn *dst = _pbn_malloc(bytes);
memcpy(dst, src, bytes);
dst->ref = 1;
@@ -108,57 +108,57 @@ struct mpn *mpn_dup(const struct mpn *src)
}
/* Produce a duplicate, possibly extended */
-struct mpn *mpn_dupx(const struct mpn *src, int len)
+struct pbn *pbn_dupx(const struct pbn *src, int len)
{
int slack = src->len >= len ? 0 : len-src->len;
- int bytes = sizeof(struct mpn)+(src->len-1)*sizeof(mpn_atom_t);
- struct mpn *dst = _mpn_malloc(bytes+slack*sizeof(mpn_atom_t));
+ int bytes = sizeof(struct pbn)+(src->len-1)*sizeof(pbn_atom_t);
+ struct pbn *dst = _pbn_malloc(bytes+slack*sizeof(pbn_atom_t));
if (!dst)
return NULL;
memcpy(dst, src, bytes);
dst->ref = 1;
- memset(&dst->num[slack], 0, slack*sizeof(mpn_atom_t));
+ memset(&dst->num[slack], 0, slack*sizeof(pbn_atom_t));
return dst;
}
/* Returns a duplicate or clears src for reuse, consumes a reference */
-struct mpn *mpn_cow(struct mpn *src, int len)
+struct pbn *pbn_cow(struct pbn *src, int len)
{
int olen = src->len;
if (src->ref <= 1) {
src->ref = 1;
if (len > olen) {
- src = _mpn_realloc(src, sizeof(struct mpn)+
- (len-1)*sizeof(mpn_atom_t));
+ src = _pbn_realloc(src, sizeof(struct pbn)+
+ (len-1)*sizeof(pbn_atom_t));
src->len = len;
}
- memset(&src->num[olen], 0, (len-olen)*sizeof(mpn_atom_t));
+ memset(&src->num[olen], 0, (len-olen)*sizeof(pbn_atom_t));
return src;
}
src->ref--;
- return mpn_dupx(src, len);
+ return pbn_dupx(src, len);
}
-/* Adjust the bits field of a specific mpn, and clear the minus flag
+/* Adjust the bits field of a specific pbn, and clear the minus flag
if the value is actually zero. */
-void _mpn_adjust_bits(struct mpn *mpn)
+void _pbn_adjust_bits(struct pbn *pbn)
{
int i;
- mpn_atom_t v;
+ pbn_atom_t v;
- for (i = mpn->len-1; i >= 0; i--) {
- v = mpn->num[i];
+ for (i = pbn->len-1; i >= 0; i--) {
+ v = pbn->num[i];
if (v) {
- mpn->bits = i*MPN_ATOM_BITS + mpn_ilog2p1(v);
+ pbn->bits = i*PBN_ATOM_BITS + pbn_ilog2p1(v);
return;
}
}
- mpn->bits = 0;
- mpn->minus = 0;
+ pbn->bits = 0;
+ pbn->minus = 0;
}
diff --git a/mpn_mul.c b/pbn_mul.c
index 5d4477b..c7b13c9 100644
--- a/mpn_mul.c
+++ b/pbn_mul.c
@@ -11,42 +11,45 @@
* ----------------------------------------------------------------------- */
/*
- * mpn_mul.c
+ * pbn_mul.c
+ *
+ * Multiply two numbers. This could be made significantly faster for
+ * very large numbers by using Karatsuba or FFT-based multiplication.
*/
-#include "mpnint.h"
+#include "pbnint.h"
-struct mpn *mpn_mul(struct mpn *s1, struct mpn *s2)
+struct pbn *pbn_mul(struct pbn *s1, struct pbn *s2)
{
size_t bits, len;
- struct mpn *d;
+ struct pbn *d;
int i, j;
- mpn_atom_t x1;
- mpn_2atom_t c;
+ pbn_atom_t x1;
+ pbn_2atom_t c;
bits = s1->bits + s2->bits;
- len = (bits+MPN_ATOM_BITS-1)/MPN_ATOM_BITS;
+ len = (bits+PBN_ATOM_BITS-1)/PBN_ATOM_BITS;
- d = mpn_new(len);
+ d = pbn_new(len);
d->bits = bits;
for (i = 0; i < s1->len; i++) {
x1 = s1->num[i];
c = 0;
for (j = 0; j < s2->len; j++) {
- c += (mpn_2atom_t)x1 * s2->num[j];
- d->num[i+j] += (mpn_atom_t)c;
- c >>= MPN_ATOM_BITS;
+ c += (pbn_2atom_t)x1 * s2->num[j];
+ d->num[i+j] += (pbn_atom_t)c;
+ c >>= PBN_ATOM_BITS;
}
if (c)
- d->num[i+j] += (mpn_atom_t)c;
+ d->num[i+j] += (pbn_atom_t)c;
}
d->minus = s1->minus ^ s2->minus;
- mpn_free(s1);
- mpn_free(s2);
+ pbn_free(s1);
+ pbn_free(s2);
- _mpn_adjust_bits(d);
+ _pbn_adjust_bits(d);
return d;
}
diff --git a/mpnint.h b/pbnint.h
index d97529d..d5a9f1f 100644
--- a/mpnint.h
+++ b/pbnint.h
@@ -11,13 +11,13 @@
* ----------------------------------------------------------------------- */
/*
- * mpn library internal header file
+ * pbn library internal header file
*/
-#ifndef MPNINT_H
-#define MPNINT_H
+#ifndef PBNINT_H
+#define PBNINT_H
-#include "mpn.h"
+#include "pbn.h"
-#endif /* MPNINT_H */
+#endif /* PBNINT_H */
diff --git a/test.c b/test.c
index e2ecc40..00a5ddf 100644
--- a/test.c
+++ b/test.c
@@ -1,55 +1,55 @@
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
-#include "mpn.h"
+#include "pbn.h"
int main(int argc, char *argv[])
{
uint64_t i, j;
- struct mpn *m, *mj;
+ struct pbn *m, *mj;
int nx = (argc < 2) ? 64 : atoi(argv[1]);
int n;
- m = mpn_int(5);
+ m = pbn_int(5);
i = 5;
n = nx;
while (n--) {
printf("%016"PRIx64" : ", i);
- mpn_dump(stdout, mpn_ref(m));
+ pbn_dump(stdout, pbn_ref(m));
putchar('\n');
i *= 5;
- m = mpn_mul(m, mpn_int(5));
+ m = pbn_mul(m, pbn_int(5));
}
- mpn_free(m);
+ pbn_free(m);
- m = mpn_int(5);
+ m = pbn_int(5);
i = 5;
n = nx;
while (n--) {
printf("%016"PRIx64" : ", i);
- mpn_dump(stdout, mpn_ref(m));
+ pbn_dump(stdout, pbn_ref(m));
putchar('\n');
i += i;
- m = mpn_add(m, mpn_ref(m));
+ m = pbn_add(m, pbn_ref(m));
}
n = nx;
j = 20;
- mj = mpn_int(20);
+ mj = pbn_int(20);
while (n--) {
printf("%016"PRIx64" : ", i);
- mpn_dump(stdout, mpn_ref(m));
+ pbn_dump(stdout, pbn_ref(m));
printf(" : ");
- mpn_dump(stdout, mpn_ref(mj));
+ pbn_dump(stdout, pbn_ref(mj));
putchar('\n');
i -= j;
j += j;
- m = mpn_sub(m, mpn_ref(mj));
- mj = mpn_add(mj, mpn_ref(mj));
+ m = pbn_sub(m, pbn_ref(mj));
+ mj = pbn_add(mj, pbn_ref(mj));
}
return 0;