speeding up Maxima by low-level hacking of simplifier
Subject: speeding up Maxima by low-level hacking of simplifier
From: Richard Fateman
Date: Sun, 03 Feb 2013 16:27:56 -0800
This is not quite perfected, but in case someone cares to look at it
with me, I changed eqtest, a program in the source file simp.lisp.
On my machine, with GCL Maxima 5.25.1 took 550 seconds (run - garbage
collect)
to do run_testsuite(time=true).
After the change, 488 seconds.
The answers to all the 9060 tests was the same except for 2, reported as:
Errors found in
C:/PROGRA~1/MAXIMA~1.1-G/share/maxima/5.25.1/tests/rtest_hypgeo.mac,
problems:
(126 190)
I'm trying to figure out why.
If you want to discuss this, ask/study..
;; here is the new code..
;; think about it.
(defun eqtest(x check &aux head )
(cond ((atom x) x)
((eq (setf head (caar x)) 'rat) x )
((and (eq head (caar check)) ;; check for structural equality
except maybe simp flag
(equal (cdr x) (cdr check)))
(put-in-simp check))
((memq 'array (cdar check))
(put-in-simp-arr x))
(t
(put-in-simp x ))))
(defun put-in-simp(w &aux flag) ;; w is a cons, e.g. ((mplus) $y $x).
(cond ((member 'simp (cdar w) :test #'eq)w) ; already has simp flag
(t
(cons
;; compute head of expression
(cond ((cdar w) ;; there is some flag, not simp. maybe array
(cons (caar w)(cons 'simp (cdar w))))
((eq (setf flag (caar w)) 'mplus) '(mplus simp)) ;; maybe
faster than checking prop list
((eq flag 'mtimes) '(mtimes simp))
((eq flag 'mexpt) '(mexpt simp))
(t (if(setf flag (get flag 'msimpind)) flag ; if msimpind, use it
(setf (get (caar w) 'msimpind)(cons (caar w) '(simp))))))
; if no msimpind flag, make one.
(cdr w)))))
(defun put-in-simp-arr(w &aux flag)
(cons (list(caar w) 'simp 'array) (cdr w)))