diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2013-11-23 01:05:33 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2013-11-23 01:05:33 +0100 |
commit | 2f9ae0f8ac8610e13ced184847b57b87fe5db580 (patch) | |
tree | f9ad2223d518585a2cfe9ea1c73e1e37d07bf637 /sys/src/cmd/unix/drawterm/libmp/mpexp.c | |
parent | ea5797c0731203c09ec5fb7172e77eab2750f1a9 (diff) |
removing (outdated) drawterm
drawterm is much better maintained by russ cox,
so removing this outdated copy.
for a more recent version, go to:
http://swtch.com/drawterm/
Diffstat (limited to 'sys/src/cmd/unix/drawterm/libmp/mpexp.c')
-rw-r--r-- | sys/src/cmd/unix/drawterm/libmp/mpexp.c | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/sys/src/cmd/unix/drawterm/libmp/mpexp.c b/sys/src/cmd/unix/drawterm/libmp/mpexp.c deleted file mode 100644 index 745057289..000000000 --- a/sys/src/cmd/unix/drawterm/libmp/mpexp.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "os.h" -#include <mp.h> -#include "dat.h" - -// res = b**e -// -// knuth, vol 2, pp 398-400 - -enum { - Freeb= 0x1, - Freee= 0x2, - Freem= 0x4, -}; - -//int expdebug; - -void -mpexp(mpint *b, mpint *e, mpint *m, mpint *res) -{ - mpint *t[2]; - int tofree; - mpdigit d, bit; - int i, j; - - t[0] = mpcopy(b); - t[1] = res; - - tofree = 0; - if(res == b){ - b = mpcopy(b); - tofree |= Freeb; - } - if(res == e){ - e = mpcopy(e); - tofree |= Freee; - } - if(res == m){ - m = mpcopy(m); - tofree |= Freem; - } - - // skip first bit - i = e->top-1; - d = e->p[i]; - for(bit = mpdighi; (bit & d) == 0; bit >>= 1) - ; - bit >>= 1; - - j = 0; - for(;;){ - for(; bit != 0; bit >>= 1){ - mpmul(t[j], t[j], t[j^1]); - if(bit & d) - mpmul(t[j^1], b, t[j]); - else - j ^= 1; - if(m != nil && t[j]->top > m->top){ - mpmod(t[j], m, t[j^1]); - j ^= 1; - } - } - if(--i < 0) - break; - bit = mpdighi; - d = e->p[i]; - } - if(m != nil){ - mpmod(t[j], m, t[j^1]); - j ^= 1; - } - if(t[j] == res){ - mpfree(t[j^1]); - } else { - mpassign(t[j], res); - mpfree(t[j]); - } - - if(tofree){ - if(tofree & Freeb) - mpfree(b); - if(tofree & Freee) - mpfree(e); - if(tofree & Freem) - mpfree(m); - } -} |