aboutsummaryrefslogtreecommitdiffstats
path: root/math/maxima/files/extra-patch-src_hayat.lisp
diff options
context:
space:
mode:
authorLorenzo Salvadore <salvadore@FreeBSD.org>2020-06-15 17:07:48 +0000
committerLorenzo Salvadore <salvadore@FreeBSD.org>2020-06-15 17:07:48 +0000
commite4ab9fe3e927234b37551f9865a28d1895f79f4c (patch)
tree388b038218e812b0e3eb9de946f3d1d546f6cafd /math/maxima/files/extra-patch-src_hayat.lisp
parent6c7fb8aad71dc7c03f9dd87deabd1c9b24a1a8e7 (diff)
math/maxima: Add ECL and SAGE options
- Add an ECL option to build maxima using ecl lisp. Option enabled by default so that Sage can work properly when using packages. [1] - Add a SAGE option (implies ECL) to apply some patches so that Sage can work properly. This option is also enabled by default to get working Sage packages. [1] - Fix a bug in xmaxima about documentation. This also introduces an XMAXIMA option (enabled by default) because to have xmaxima working we need to ensure that DOCS and TEST are enabled, which is done by using XMAXIMA_IMPLIES. This also has the advantage to remove USES= tk for users who want to disable XMAXIMA. [2] - Modify TEST option so that it only installs tests, but it does not run them any more in the post-build-TEST-on target. Tests can still be run using "make test". Submitted by: thierry (based on) [1] Reported by: thierry [2] Approved by: thierry, tcberner (co-mentor) Differential Revision: https://reviews.freebsd.org/D24959
Diffstat (limited to 'math/maxima/files/extra-patch-src_hayat.lisp')
-rw-r--r--math/maxima/files/extra-patch-src_hayat.lisp86
1 files changed, 86 insertions, 0 deletions
diff --git a/math/maxima/files/extra-patch-src_hayat.lisp b/math/maxima/files/extra-patch-src_hayat.lisp
new file mode 100644
index 000000000000..f521215661a3
--- /dev/null
+++ b/math/maxima/files/extra-patch-src_hayat.lisp
@@ -0,0 +1,86 @@
+--- src/hayat.lisp.orig 2019-10-21 03:38:59 UTC
++++ src/hayat.lisp
+@@ -2205,6 +2205,25 @@
+ (or (alike1 (exp-pt (get-datum (datum-var (car l)))) (exp-pt (car l)))
+ (return () ))))
+
++;; Patch borrowed from SageMath: 0001-taylor2-Avoid-blowing-the-stack-when-diff-expand-isn
++;;
++;; 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 () ))
+@@ -2248,9 +2267,32 @@
+ ((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)
+ ((or (null b) (null c) (null d)) () )
+@@ -3024,7 +3066,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