From: Robert D. <rob...@us...> - 2012-11-14 23:01:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Maxima, A Computer Algebra System". The branch, master has been updated via e7f991bca3b4e287b164f84a702bb29e69cae393 (commit) via c36715e95ed0ae84729de4bae6dfccefa0929e2d (commit) from ed0035a8f290a91e0cc4c5768bd179312fe529b1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e7f991bca3b4e287b164f84a702bb29e69cae393 Merge: c36715e ed0035a Author: robert_dodier <rob...@us...> Date: Wed Nov 14 15:59:33 2012 -0700 Merge branch 'master' of ssh://maxima.git.sourceforge.net/gitroot/maxima/maxima commit c36715e95ed0ae84729de4bae6dfccefa0929e2d Author: robert_dodier <rob...@us...> Date: Wed Nov 14 15:58:19 2012 -0700 Fix bugs in code to handle rat expressions: VARLIST leakage. Fixes bug reported to mailing list 2012-11-07: "trigrat" caught in infinite loop - depending on how you call it diff --git a/src/rat3e.lisp b/src/rat3e.lisp index 89426f3..f873a26 100644 --- a/src/rat3e.lisp +++ b/src/rat3e.lisp @@ -170,14 +170,14 @@ (reverse (mapfr1 cdrl nil)))) (defmfun $rat (e &rest vars) - (cond ((not (null vars)) - (let (varlist) + (let (varlist) + (cond ((not (null vars)) (joinvarlist vars) (lnewvar e) - (rat0 e))) + (rat0 e)) (t (lnewvar e) - (rat0 e)))) + (rat0 e))))) (defun rat0 (exp) ;SIMP FLAGS? (if (mbagp exp) @@ -952,7 +952,7 @@ (defmfun $ratexpand (x) (if (mbagp x) (cons (car x) (mapcar '$ratexpand (cdr x))) - (let (($ratexpand t) ($ratfac nil)) + (let (($ratexpand t) ($ratfac nil) varlist) (ratdisrep (ratf x))))) (defun pdisrep*expand (a b) diff --git a/src/simp.lisp b/src/simp.lisp index 78d5fc8..6157622 100644 --- a/src/simp.lisp +++ b/src/simp.lisp @@ -960,7 +960,8 @@ st1 (cond ((atom w) nil) ((eq (caar w) 'mrat) - (cond ((or eqnflag + (let (varlist) + (cond ((or eqnflag matrixflag (and sumflag (not (member 'trunc (cdar w) :test #'eq))) @@ -971,7 +972,7 @@ (return (ratf (cons '(mplus) (nconc (mapcar #'simplify (cons w (cdr x))) - (cdr res)))))))) + (cdr res))))))))) ((eq (caar w) 'mequal) (setq eqnflag (if (not eqnflag) @@ -1633,7 +1634,8 @@ st1 (cond ((atom w) nil) ((eq (caar w) 'mrat) - (cond ((or eqnflag matrixflag + (let (varlist) + (cond ((or eqnflag matrixflag (and sumflag (not (member 'trunc (cdar w) :test #'eq))) (spsimpcases (cdr x) w)) @@ -1643,7 +1645,7 @@ (return (ratf (cons '(mtimes) (nconc (mapcar #'simplify (cons w (cdr x))) - (cdr res)))))))) + (cdr res))))))))) ((eq (caar w) 'mequal) (setq eqnflag (if (not eqnflag) diff --git a/tests/rtest15.mac b/tests/rtest15.mac index a727cd5..237b6fe 100644 --- a/tests/rtest15.mac +++ b/tests/rtest15.mac @@ -166,6 +166,54 @@ sin(1); trigrat((cos(x)+(sqrt(3)+2)*sin(x)-4*sin(5*%pi/12)*cos(x-(7*%pi)/12))/cos(x)); 2; +/* bug reported to mailing list 2012-11-07 '"trigrat" caught in infinite loop - depending on how you call it' + * I didn't check the trigrat outputs -- these tests only verify that the return value is the same across trigrat calls + */ + +(e : 2*x/(sqrt(y)+x) - (x^2/((sqrt(y)+x)^2)), 0); +0; + +trigrat (e); +(2*%i*sin(3*atan2(0,y)/2)*x*abs(y)^(3/2) + +2*cos(3*atan2(0,y)/2)*x*abs(y)^(3/2)-3*x^2*y+x^4) + /(y^2-2*x^2*y+x^4); + +trigrat (xthru (e)); +(2*%i*sin(3*atan2(0,y)/2)*x*abs(y)^(3/2) + +2*cos(3*atan2(0,y)/2)*x*abs(y)^(3/2)-3*x^2*y+x^4) + /(y^2-2*x^2*y+x^4); + +/* +(trigrat (e), trigrat (xthru (e))); +(2*%i*sin(3*atan2(0,y)/2)*x*abs(y)^(3/2) + +2*cos(3*atan2(0,y)/2)*x*abs(y)^(3/2)-3*x^2*y+x^4) + /(y^2-2*x^2*y+x^4); + */ + +/* +[trigrat (e), trigrat (xthru (e))]; +[(2*%i*sin(3*atan2(0,y)/2)*x*abs(y)^(3/2) + +2*cos(3*atan2(0,y)/2)*x*abs(y)^(3/2)-3*x^2*y+x^4) + /(y^2-2*x^2*y+x^4), +(2*%i*sin(3*atan2(0,y)/2)*x*abs(y)^(3/2) + +2*cos(3*atan2(0,y)/2)*x*abs(y)^(3/2)-3*x^2*y+x^4) + /(y^2-2*x^2*y+x^4)]; + */ + +(trigrat (xthru (e)), trigrat (e)); +(2*%i*sin(3*atan2(0,y)/2)*x*abs(y)^(3/2) + +2*cos(3*atan2(0,y)/2)*x*abs(y)^(3/2)-3*x^2*y+x^4) + /(y^2-2*x^2*y+x^4); + +(e : 1 / (y + sqrt (y)), 0); +0; + +[trigrat (e), trigrat (e)]; +["*"(-1, "^"("+"("*"(-1, y), "^"(y, 2)), -1), "+"("*"(-1, y), "*"(cos("*"("/"(1, 2), atan2(0, y))), "^"(abs(y), "/"(1, 2))), + "*"(%i, sin("*"("/"(1, 2), atan2(0, y))), "^"(abs(y), "/"(1, 2))))), +"*"(-1, "^"("+"("*"(-1, y), "^"(y, 2)), -1), "+"("*"(-1, y), "*"(cos("*"("/"(1, 2), atan2(0, y))), "^"(abs(y), "/"(1, 2))), + "*"(%i, sin("*"("/"(1, 2), atan2(0, y))), "^"(abs(y), "/"(1, 2)))))]; + /* compile() will fail with gcl if gcc not installed */ f(x):=x+2; f(x):=x+2; ----------------------------------------------------------------------- Summary of changes: src/rat3e.lisp | 10 +++++----- src/simp.lisp | 10 ++++++---- tests/rtest15.mac | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) hooks/post-receive -- Maxima, A Computer Algebra System |