|
From: willisbl <wil...@us...> - 2025-12-01 10:39:26
|
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 7a7b1a6ea31e4cdbcd09a824c8abbc57d50b0ce8 (commit)
from 7b6f5cde1a84c8b4a795fccc0e53c3bb74e32aba (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 7a7b1a6ea31e4cdbcd09a824c8abbc57d50b0ce8
Author: Barton Willis <wi...@un...>
Date: Mon Dec 1 04:39:11 2025 -0600
Fix for #4636 signum(ind) is an error
- In the signum simplifier, catch errors from the call to `csign`. This allows `signum(ind)` to return a `signum` nounform.
- Added a test to `rtest_signum.mac` for this bug, along with additional tests for overflow and underflow in signum expressions.
- Updated a few other tests in `rtest_signum.mac`.
No unexpected failures in the testsuite or share testsuite with SBCL 2.4.7 or Clozure 1.13.
diff --git a/src/simp.lisp b/src/simp.lisp
index 28ec6502a..1a1b97d41 100644
--- a/src/simp.lisp
+++ b/src/simp.lisp
@@ -1868,7 +1868,9 @@
x)
(t
- (setq sgn ($csign x))
+ ;; Let's catch errors from $csign. Doing so allows signum(ind) to return a signum nounform, for example.
+ (setq sgn (car (let (($errormsg nil) (errcatch t) (errset nil)) (errset ($csign x)))))
+
(cond ((eq sgn '$neg) -1)
((eq sgn '$zero) 0)
((eq sgn '$pos) 1)
diff --git a/tests/rtest_signum.mac b/tests/rtest_signum.mac
index 213182dfb..c6736c8a9 100644
--- a/tests/rtest_signum.mac
+++ b/tests/rtest_signum.mac
@@ -48,17 +48,17 @@ signum(x^2 + 1);
(declare(z, complex),0);
0$
-signum(z);
-signum(z)$
+block([ans : signum(z)], [op(ans), args(ans)]);
+[signum,[z]]$
signum(%i);
-signum(%i)$
+%i$
signum(%i - 6);
-signum(%i - 6)$
+%i/sqrt(37)-6/sqrt(37)$
-signum(z^2 + 1);
-signum(z^2 + 1)$
+block([ans : signum(z^2 + 1)],[op(ans), args(ans)]);
+[signum,[z^2+1]]$
(assume(p > 0, n < 0, pz >= 0, nz <= 0),0);
0$
@@ -227,3 +227,54 @@ b^2$
integrate(mod(x,b),x,0,42*b);
21*b^2$
+
+/* \# 4636 signum(ind) is an error */
+block([ans : signum(ind)], [op(ans),args(ans)]);
+[signum, [ind]]$
+
+block([ans : signum(infinity)], [op(ans),args(ans)]);
+[signum, [infinity]]$
+
+block([ans : signum(und)], [op(ans),args(ans)]);
+[signum, [und]]$
+
+/* overflow/underflow cases also reported in \# 4636 */
+signum(1e-170);
+1.0$
+
+signum(-1e-170);
+-1.0$
+
+signum(1e308);
+1.0$
+
+signum(-1e308);
+-1.0$
+
+signum(1e-170 + %i*1e-170);
+0.7071067811865475*%i + 0.7071067811865475$
+
+signum(1e170 + %i*1e+170);
+0.7071067811865475 * %i + 0.7071067811865475$
+
+signum(1e170);
+1.0$
+
+/* complex numbers */
+signum(5+%i*7);
+(7*%i)/sqrt(74)+5/sqrt(74)$
+
+signum(3.4 + %i);
+0.28216632399155017*%i+0.9593655015712705$
+
+signum(3.4 + %i/15);
+0.019604074934445576*%i+0.9998078216567245$
+
+signum(3.4b0 + %i/15);
+1.96040749344455786124536b-2*%i+9.99807821656724509235131b-1$
+
+facts();
+[]$
+
+contexts;
+[initial, global]$
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
src/simp.lisp | 4 +++-
tests/rtest_signum.mac | 63 +++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 60 insertions(+), 7 deletions(-)
hooks/post-receive
--
Maxima CAS
|