I have coded a squaring function for polynomials in finite fields. As
expected it is roughly 1.8 times faster than multiplying poly*poly with
rat3a/ptimes, wich is the underlying lisp function for Maxima level
fasttimes.
To multiply the coefficients the function ptimes uses ctimes, which
multiplies and reduces the result by a balanced modulus. From rat3a:
(defmacro mcmod (n) ;;; gives answers from -modulus/2 ...0 1 2 +modulus/2
`(let ((.n. (mod ,n modulus)))
(cond ((<= (* 2 .n.) modulus) .n.)
(t (- .n. modulus)))))
(defun ctimes (a b)
(cond ((null modulus) (* a b))
(t (mcmod (* a b)))))
In my squaring function I want to replace each (ctimes a b) by simply (mod
(* a b) modulus). I need positive results.
As expected with clisp and sbcl this replacement is faster than ctimes, but
with gcl this replacement (which does less!) slows down the whole function
by a factor 3.
Is there a hidden secret about ctimes with gcl? Any hints are welcome.
Volker van Nek