From: Raymond T. <rt...@us...> - 2006-03-17 14:00:06
|
Update of /cvsroot/maxima/maxima/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10975/src Modified Files: factor.lisp ratmac.lisp Log Message: src/factor.lisp: o Change primcyclo to bind a gensym to *g* and give it a value. This fixes the bug 1449163: ratsimp(exp(%pi*%i/9)/(x-2)^(1/7)) causes error. src/ratmac.lisp: o Add a historical comment on what pointergp does. Index: factor.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/src/factor.lisp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- factor.lisp 7 Nov 2005 17:37:11 -0000 1.6 +++ factor.lisp 17 Mar 2006 13:59:59 -0000 1.7 @@ -61,6 +61,7 @@ (defun csqfrp ($factorflag) (null (zl-delete 1 (oddelm (cdr (cfactor $factorflag)))))) +#+nil (defun primcyclo (n &aux *g* (nl (cfactorw n))) (setq nl (loop for (c e) on nl by #'cddr nconc (*make-list e c))) @@ -69,6 +70,16 @@ ((eql 0 res) nil) (t (list 0 res))))) +(defun primcyclo (n) + (let ((*g* (gensym "PRIMCYCLO-")) + (nl (loop for (c e) on (cfactorw n) by #'cddr + nconc (*make-list e c)))) + (setf (symbol-value *g*) 0) + (let ((res (cyclotomic (list n nl)))) + (cond ((consp res) (p-terms res)) + ((eql 0 res) nil) + (t (list 0 res)))))) + (defun factxn+-1 (p) (let ((*g* (car p)) ($factorflag t)) @@ -1417,4 +1428,4 @@ ;;(DEFMVAR *ALPHA (CAR BIGPRIMES)) - \ No newline at end of file + Index: ratmac.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/src/ratmac.lisp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ratmac.lisp 7 Nov 2005 17:37:12 -0000 1.5 +++ ratmac.lisp 17 Mar 2006 13:59:59 -0000 1.6 @@ -58,8 +58,27 @@ (defmacro valput (item val) `(setf (valget ,item) ,val)) +;; A historical note from Richard Fateman, on the maxima list, +;; 2006/03/17: +;; +;; "The name pointerp comes from the original hack when we wanted a +;; bunch of atoms that could be ordered fast, we just generated, say, +;; 10 gensyms. Then we sorted them by the addresses of the symbols in +;; memory. Then we associated them with x,y,z,.... This meant that +;; pointergp was one or two instructions on a PDP-10, in assembler." +;; +;; "That version of pointergp turned out to be more trouble than it was +;; worth because we sometimes had to interpolate between two gensym +;; "addresses" and to do that we had to kind of renumber too much of +;; the universe. Or maybe we just weren't clever enough to do it +;; without introducing bugs." +;; +;; Richard Fateman also says pointergp needs to be fast because it's +;; called a lot. So if you get an error from pointergp, it's probably +;; because someone forgot to initialize things correctly. (proclaim '(inline pointergp)) -(defun pointergp (a b) (f> (valget a) (valget b))) +(defun pointergp (a b) + (f> (valget a) (valget b))) ;;(macro ALGV (L) `(AND $ALGEBRAIC (GET ,(CADR L) 'TELLRAT))) (defmacro algv (v) |