[maxima-sage] 04/05: Import 2 patches from Sage to fix failing doctests.

Tobias Hansen thansen at moszumanska.debian.org
Sat Oct 15 23:12:11 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository maxima-sage.

commit 17e70be6d557973b151d8913d85d43bf2090bd5b
Author: Tobias Hansen <tobias.han at gmx.de>
Date:   Thu Mar 12 20:31:56 2015 +0100

    Import 2 patches from Sage to fix failing doctests.
---
 ...id-blowing-the-stack-when-diff-expand-isn.patch | 95 ++++++++++++++++++++++
 debian/patches/build-fasl.patch                    |  2 +-
 debian/patches/matrixexp.patch                     | 13 +++
 debian/patches/series                              |  2 +
 4 files changed, 111 insertions(+), 1 deletion(-)

diff --git a/debian/patches/0001-taylor2-Avoid-blowing-the-stack-when-diff-expand-isn.patch b/debian/patches/0001-taylor2-Avoid-blowing-the-stack-when-diff-expand-isn.patch
new file mode 100644
index 0000000..56e6f2c
--- /dev/null
+++ b/debian/patches/0001-taylor2-Avoid-blowing-the-stack-when-diff-expand-isn.patch
@@ -0,0 +1,95 @@
+--- a/src/hayat.lisp
++++ b/src/hayat.lisp
+@@ -2189,6 +2189,23 @@
+       (or (alike1 (exp-pt (get-datum (datum-var (car l)))) (exp-pt (car l)))
+ 	  (return () ))))
+ 
++;; SUBTREE-SEARCH
++;;
++;; Search for subtrees, ST, of TREE that contain an element equal to BRANCH
++;; under TEST as an immediate child and return them as a list.
++;;
++;; Examples:
++;;   (SUBTREE-SEARCH 2 '(1 2 3)) => '((1 2 3))
++;;   (SUBTREE-SEARCH 2 '(1 2 2 3)) => '((1 2 2 3))
++;;   (SUBTREE-SEARCH 2 '(1 (2) 3)) => '((2))
++;;   (SUBTREE-SEARCH 4 '(1 (2) 3)) => NIL
++;;   (SUBTREE-SEARCH 2 '(1 (2) 3 (2))) => '((2) (2))
++
++(defun subtree-search (branch tree &optional (test 'equalp))
++  (unless (atom tree)
++    (if (find branch tree :test test) (list tree)
++        (mapcan (lambda (child) (subtree-search branch child test)) tree))))
++
+ (defun taylor2  (e)
+  (let ((last-exp e))	    ;; lexp-non0 should be bound here when needed
+   (cond ((assolike e tlist) (var-expand e 1 () ))
+@@ -2232,8 +2249,31 @@
+ 		 ((null l) t)
+ 		 (or (free e (car l)) (return ()))))
+ 	 (newsym e))
+-	(t (let ((exact-poly () ))	; Taylor series aren't exact
+-	      (taylor2 (diff-expand e tlist)))))))
++	(t
++         ;; When all else fails, call diff-expand to try to expand e around the
++         ;; point as a Taylor series by taking repeated derivatives. This might
++         ;; fail, unfortunately: If a required derivative doesn't exist, then
++         ;; DIFF-EXPAND will return a form of the form "f'(x)" with the
++         ;; variable, rather than the expansion point in it.
++         ;;
++         ;; Sometimes this works - in particular, if there is a genuine pole at
++         ;; the point, we end up passing a sum of terms like x^(-k) to a
++         ;; recursive invocation and all is good. Unfortunately, it can also
++         ;; fail. For example, if e is abs(sin(x)) and we try to expand to first
++         ;; order, the expression "1/1*(cos(x)*sin(x)/abs(sin(x)))*x^1+0" is
++         ;; returned. If we call taylor2 on that, we will end up recursing and
++         ;; blowing the stack. To avoid doing so, error out if EXPANSION
++         ;; contains E as a subtree. However, don't error if it occurs as an
++         ;; argument to %DERIVATIVE (in which case, we might well be fine). This
++         ;; happens from things like taylor(log(f(x)), x, x0, 1).
++
++         (let* ((exact-poly nil) ; (Taylor series aren't exact)
++                (expansion (diff-expand e tlist)))
++           (when (find-if (lambda (subtree)
++                            (not (eq ($op subtree) '%derivative)))
++                          (subtree-search e expansion))
++             (exp-pt-err))
++           (taylor2 expansion))))))
+ 
+ (defun compatvarlist (a b c d)
+    (cond ((null a) t)
+@@ -2968,7 +3008,21 @@
+        (and (or (member '$inf pt-list :test #'eq) (member '$minf pt-list :test #'eq))
+ 	    (unfam-sing-err)))
+ 
+-(defun diff-expand (exp l)		;l is tlist
++;; DIFF-EXPAND
++;;
++;; Expand EXP in the variables as specified in L, which is a list of tlists. If
++;; L is a singleton, this just works by the classic Taylor expansion:
++;;
++;;    f(x) = f(c) + f'(c) + f''(c)/2 + ... + f^(k)(c)/k!
++;;
++;; If L specifies multiple expansions, DIFF-EXPAND works recursively by
++;; expanding one variable at a time. The derivatives are computed using SDIFF.
++;;
++;; In some cases, f'(c) or some higher derivative might be an expression of the
++;; form 1/0. Instead of returning an error, DIFF-EXPAND uses f'(x)
++;; instead. (Note: This seems bogus to me (RJS), but I'm just describing how
++;; EVAL-DERIV works)
++(defun diff-expand (exp l)
+   (check-inf-sing (mapcar (function caddr) l))
+   (cond ((not l) exp)
+ 	(t
+--- a/tests/rtest_taylor.mac
++++ b/tests/rtest_taylor.mac
+@@ -539,3 +539,9 @@
+  + 2856700692480*x^2  + 3370143559680*x + 2386516803584)],
+  pade (t, 5, 5), is (equal (%%, foo)));
+ true;
++
++/* Avoid blowing the stack if diff-expand doesn't return anything
++   helpful. Example comes from Bug ID: 2520
++ */
++errcatch(taylor (sin(x)/abs(sin(x)), x, 0, 0))$
++[];
diff --git a/debian/patches/build-fasl.patch b/debian/patches/build-fasl.patch
index 48a3ea0..e478667 100644
--- a/debian/patches/build-fasl.patch
+++ b/debian/patches/build-fasl.patch
@@ -7,7 +7,7 @@ Origin: http://git.sagemath.org/sage.git/tree/build/pkgs/maxima/patches/build-fa
 
 --- a/src/maxima.system
 +++ b/src/maxima.system
-@@ -76,6 +76,11 @@
+@@ -75,6 +75,11 @@
  			     ;; Convert dir/foo.fas to dir/foo.o
  			     (make-pathname :type "o" :defaults p))
  			 files)))
diff --git a/debian/patches/matrixexp.patch b/debian/patches/matrixexp.patch
new file mode 100644
index 0000000..a9318b0
--- /dev/null
+++ b/debian/patches/matrixexp.patch
@@ -0,0 +1,13 @@
+--- a/share/linearalgebra/matrixexp.lisp
++++ b/share/linearalgebra/matrixexp.lisp
+@@ -138,8 +138,8 @@
+ 	   (print `(ratvars = ,$ratvars gcd = '$gcd algebraic = ,$algebraic))
+ 	   (print `(ratfac = ,$ratfac))
+ 	   (merror "Unable to find the spectrum")))
+-   
+-    (setq res ($fullratsimp (ncpower (sub (mult z ($ident n)) mat) -1) z))
++
++    (setq res ($fullratsimp ($invert_by_lu (sub (mult z ($ident n)) mat) '$crering) z))
+     (setq m (length sp))
+     (dotimes (i m)
+       (setq zi (nth i sp))
diff --git a/debian/patches/series b/debian/patches/series
index 113fe30..0098b86 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,5 @@ fix_closeto_test
 cl_info_separate_index_dir
 do_not_remake_docs_2
 build-fasl.patch
+0001-taylor2-Avoid-blowing-the-stack-when-diff-expand-isn.patch
+matrixexp.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/maxima-sage.git



More information about the debian-science-commits mailing list