summaryrefslogtreecommitdiff
path: root/sys/src/libmp/port/mpaux.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-12-16 21:18:20 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-12-16 21:18:20 +0100
commitefd3ac8a2328d1baf55c296a00807052473d549e (patch)
tree3e0851312267fee156a3cfb67aea5b4faebbfb76 /sys/src/libmp/port/mpaux.c
parentb6f04b77e3d11699d664d0ca7d0ba991f9599acc (diff)
libmp: add mpfield() function for fast field arithmetic
instead of testing for special field primes each time in mpmod(), make it explicit with a mpfiled() function that tests a modulus N to be of some special form that can be reduced more efficiently with some precalculation, and replaces N with a Mfield* when it can. the Mfield*'s are recognized by mpmod() as they have the MPfield flag set and provide a function pointer that executes the fast reduction.
Diffstat (limited to 'sys/src/libmp/port/mpaux.c')
-rw-r--r--sys/src/libmp/port/mpaux.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/src/libmp/port/mpaux.c b/sys/src/libmp/port/mpaux.c
index eb70a9364..f85e782a9 100644
--- a/sys/src/libmp/port/mpaux.c
+++ b/sys/src/libmp/port/mpaux.c
@@ -137,7 +137,7 @@ mpcopy(mpint *old)
setmalloctag(new, getcallerpc(&old));
new->sign = old->sign;
new->top = old->top;
- new->flags = old->flags & ~MPstatic;
+ new->flags = old->flags & ~(MPstatic|MPfield);
memmove(new->p, old->p, Dbytes*old->top);
return new;
}
@@ -152,7 +152,7 @@ mpassign(mpint *old, mpint *new)
new->sign = old->sign;
new->top = old->top;
new->flags &= ~MPnorm;
- new->flags |= old->flags & ~MPstatic;
+ new->flags |= old->flags & ~(MPstatic|MPfield);
memmove(new->p, old->p, Dbytes*old->top);
}