diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-04-27 14:35:13 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-04-27 14:35:13 +0200 |
| commit | 659a5a81045af899310dca5f70907da287c56d19 (patch) | |
| tree | 833b6e637a4a7ccadaea45567d5ff87f192e1eb3 /src/zmodpowu.c | |
| parent | Add error checking to tomsfastmath translation and sort includes (diff) | |
| download | libzahl-659a5a81045af899310dca5f70907da287c56d19.tar.gz libzahl-659a5a81045af899310dca5f70907da287c56d19.tar.bz2 libzahl-659a5a81045af899310dca5f70907da287c56d19.tar.xz | |
Optimise zpowu and zmodpowu
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zmodpowu.c')
| -rw-r--r-- | src/zmodpowu.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/zmodpowu.c b/src/zmodpowu.c index c9c8af5..fd5e925 100644 --- a/src/zmodpowu.c +++ b/src/zmodpowu.c @@ -27,9 +27,11 @@ zmodpowu(z_t a, z_t b, unsigned long long int c, z_t d) zset(td, d); zsetu(a, 1); - for (; c; c >>= 1) { + if (c & 1) + zmodmul(a, a, tb, td); + while (c >>= 1) { + zmodsqr(tb, tb, td); if (c & 1) zmodmul(a, a, tb, td); - zmodsqr(tb, tb, td); } } |
