|
From: tomasriker <tom...@us...> - 2026-06-03 11:00:38
|
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 CAS".
The branch, master has been updated
via 4c2ce86affd66fae5d9d9331cc0761725b2155fd (commit)
from 8ccfb47b479bcd135ee901916624479154eabeaa (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 4c2ce86affd66fae5d9d9331cc0761725b2155fd
Author: David Scherfgen <d.s...@go...>
Date: Wed Jun 3 13:00:31 2026 +0200
Fix SIGN handling of subscripted functions and introduce DECL-IMAGINARYP
This fixes bug #4752.
SIGN, when in complex mode, would only look at the CAAR of an expression, which
isn't correct for subscripted functions.
To make the code more consistent, introduce DECL-IMAGINARYP along the existing
DECL-REALP and DECL-COMPLEXP functions and use it instead of $FEATUREP for
symbols.
diff --git a/src/compar.lisp b/src/compar.lisp
index 4fddd039a..a6776204f 100644
--- a/src/compar.lisp
+++ b/src/compar.lisp
@@ -1373,20 +1373,17 @@ TDNEG TDZERO TDPN) to store it, and also sets SIGN."
(t (sign-any x)))))))
(defun sign-any (x)
+ (let (op)
(cond ((and *complexsign*
(symbolp x)
(decl-complexp x))
;; In Complex Mode look for symbols declared to be complex.
- (if ($featurep x '$imaginary)
- (setq sign '$imaginary)
- (setq sign '$complex)))
+ (setq sign (if (decl-imaginaryp x) '$imaginary '$complex)))
((and *complexsign*
(not (atom x))
- (decl-complexp (caar x)))
- ;; A function f(x), where f is declared to be imaginary or complex.
- (if ($featurep (caar x) '$imaginary)
- (setq sign '$imaginary)
- (setq sign '$complex)))
+ (decl-complexp (setq op (if (mqapplyp x) (subfunname x) (caar x)))))
+ ;; A function f(x) or f[n](x), where f is declared to be imaginary or complex.
+ (setq sign (if (decl-imaginaryp op) '$imaginary '$complex)))
(t
(dcompare x 0)
(if (and $assume_pos
@@ -1399,7 +1396,7 @@ TDNEG TDZERO TDPN) to store it, and also sets SIGN."
(setq sign '$pos))
(setq minus nil evens nil
odds (if (not (member sign '($pos $neg $zero) :test #'eq))
- (ncons x))))))
+ (ncons x)))))))
(defun sign-mtimes (x)
(setq x (cdr x))
diff --git a/src/simp.lisp b/src/simp.lisp
index a24af4507..3d907dd5f 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -2779,11 +2779,15 @@
(defun decl-complexp (e)
(kindp e '$complex))
-;; TRUE, if the symbol e is declared to be $real, $rational, $irrational
-;; or $integer
+;; TRUE, if the symbol e is declared to be $real, $rational, $irrational,
+;; $integer, $even or $odd.
(defun decl-realp (e)
(kindp e '$real))
+;; TRUE, if the symbol e is declared to be $imaginary.
+(defun decl-imaginaryp (e)
+ (kindp e '$imaginary))
+
;; WARNING: Exercise extreme caution when modifying this function!
;;
;; Richard Fateman and Stavros Macrakis both say that changing the
diff --git a/tests/rtest_sign.mac b/tests/rtest_sign.mac
index e83d91993..6cf9ad656 100644
--- a/tests/rtest_sign.mac
+++ b/tests/rtest_sign.mac
@@ -1665,3 +1665,17 @@ forget(x > -1, x < 1);
is(abs(cos(x)) <= 1);
true;
+
+/* Bug #4752: "csign doesn't handle subscripted functions like li correctly" */
+
+csign(li[n](x));
+complex;
+
+declare(f, imaginary);
+done;
+
+csign(f[n](x));
+imaginary;
+
+forget(kind(f, imaginary));
+[kind(f, imaginary)];
-----------------------------------------------------------------------
Summary of changes:
src/compar.lisp | 15 ++++++---------
src/simp.lisp | 8 ++++++--
tests/rtest_sign.mac | 14 ++++++++++++++
3 files changed, 26 insertions(+), 11 deletions(-)
hooks/post-receive
--
Maxima CAS
|