summaryrefslogtreecommitdiffstats
path: root/modular.scm
diff options
context:
space:
mode:
authorThomas Bushnell, BSG <tb@debian.org>2007-12-28 16:25:32 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:39 -0800
commitd8ae23691ed6392b7f320f5fa7d4dd78ae52c10e (patch)
treeb20b8bc02e854c4c86d39ee22a0638a8b06e01af /modular.scm
parentedd1ebef3ad774e7cbcc2f5918d555bfb0b44091 (diff)
parent64f037d91e0c9296dcaef9a0ff3eb33b19a2ed34 (diff)
downloadslib-d8ae23691ed6392b7f320f5fa7d4dd78ae52c10e.tar.gz
slib-d8ae23691ed6392b7f320f5fa7d4dd78ae52c10e.zip
Import Debian changes 3a5-1debian/3a5-1
slib (3a5-1) unstable; urgency=low * New upstream release. * slib.texi (Library Catalogs): Repeat change from 3a3-3. * Makefile: Repeat $(htmldir)slib_toc.html changes from 3a2-1. * guile.init: (library-vicinity): Repeat change from 3a4-2. * debian/rules (binary-indep): Don't hide .init files in a separate subdirectory, thus conforming better to the usual slib practice. Put a symlink in place to ease transitions. (Closes: #407370).
Diffstat (limited to 'modular.scm')
-rw-r--r--modular.scm44
1 files changed, 23 insertions, 21 deletions
diff --git a/modular.scm b/modular.scm
index e77ced4..78c78bb 100644
--- a/modular.scm
+++ b/modular.scm
@@ -185,32 +185,34 @@
(lambda (m a b)
(define a0 a)
(define p 0)
-
(cond
((zero? m) (* a b))
((negative? m)
;; Need algorighm to work with symmetric representation.
- (modular:normalize m (* a b)))
+ (modular:normalize m (* (modular:normalize m a)
+ (modular:normalize m b))))
(else
- (cond
- ((< a modular:r))
- ((< b modular:r) (set! a b) (set! b a0) (set! a0 a))
- (else
- (set! a0 (modulo a modular:r))
- (let ((a1 (quotient a modular:r))
- (qh (quotient m modular:r))
- (rh (modulo m modular:r)))
- (cond ((>= a1 modular:r)
- (set! a1 (- a1 modular:r))
- (set! p (modulo (- (* modular:r (modulo b qh))
- (* (quotient b qh) rh)) m))))
- (cond ((not (zero? a1))
- (let ((q (quotient m a1)))
- (set! p (- p (* (quotient b q) (modulo m a1))))
- (set! p (modulo (+ (if (positive? p) (- p m) p)
- (* a1 (modulo b q))) m)))))
- (set! p (modulo (- (* modular:r (modulo p qh))
- (* (quotient p qh) rh)) m)))))
+ (set! a (modulo a m))
+ (set! b (modulo b m))
+ (set! a0 a)
+ (cond ((< a modular:r))
+ ((< b modular:r) (set! a b) (set! b a0) (set! a0 a))
+ (else
+ (set! a0 (modulo a modular:r))
+ (let ((a1 (quotient a modular:r))
+ (qh (quotient m modular:r))
+ (rh (modulo m modular:r)))
+ (cond ((>= a1 modular:r)
+ (set! a1 (- a1 modular:r))
+ (set! p (modulo (- (* modular:r (modulo b qh))
+ (* (quotient b qh) rh)) m))))
+ (cond ((not (zero? a1))
+ (let ((q (quotient m a1)))
+ (set! p (- p (* (quotient b q) (modulo m a1))))
+ (set! p (modulo (+ (if (positive? p) (- p m) p)
+ (* a1 (modulo b q))) m)))))
+ (set! p (modulo (- (* modular:r (modulo p qh))
+ (* (quotient p qh) rh)) m)))))
(if (zero? a0)
p
(let ((q (quotient m a0)))