|
From: <ap...@us...> - 2026-06-04 15:51:18
|
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 6f964815a3c43b118de53d80ee68ad54daf5c032 (commit)
from 909aa61d7716451bf9061aeb57ef2cf43808a84b (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 6f964815a3c43b118de53d80ee68ad54daf5c032
Author: Robert Dodier <rob...@so...>
Date: Thu Jun 4 08:43:05 2026 -0700
Package ezunits: call sublis instead of subst in the macro "dimensionally",
which resolves a bug reported to maxima-discuss 2026-06-01, "Solving Equation with Ezunits Problem".
sublist makes substitutions in parallel, while subst makes them in sequence;
subst calls SIMPLIFYA between one substitution and the next.
The result was that subst was creating an expression of the form (a`foo + b`bar)`baz
which is handled incorrectly by "``" -- now the result is a`foo*baz + b`bar*baz,
which is handled correctly.
Another way to resolve this would be to make "`" distribute over "+" --
might want to do that too. In any event, parallel substitution makes
more sense than serial, since the substitutions are independent.
diff --git a/share/ezunits/ezunits_functions.mac b/share/ezunits/ezunits_functions.mac
index bf99a637a..2756f8dcf 100644
--- a/share/ezunits/ezunits_functions.mac
+++ b/share/ezunits/ezunits_functions.mac
@@ -642,8 +642,8 @@ dimensionally (e%) ::=
units_gensyms : make_array ('hashed),
unitless_args : applyb1 (e%_args, rununitify),
reunitification_eqs : map (lambda ([e], lhs (e) = 1 ` rhs (e)), inverse_gensym_map (units_gensyms)),
- reunitified : subst (reunitification_eqs, apply (e%_op, unitless_args)),
- rezeroified : subst (makelist (x = 0, x, listarray (qtys_gensyms)), reunitified),
+ reunitified : sublis (reunitification_eqs, apply (e%_op, unitless_args)),
+ rezeroified : sublis (makelist (x = 0, x, listarray (qtys_gensyms)), reunitified),
killcontext (context_name),
rezeroified));
diff --git a/share/ezunits/rtest_ezunits_mroz_examples.mac b/share/ezunits/rtest_ezunits_mroz_examples.mac
index 894958284..f624b0a98 100644
--- a/share/ezunits/rtest_ezunits_mroz_examples.mac
+++ b/share/ezunits/rtest_ezunits_mroz_examples.mac
@@ -50,3 +50,23 @@ true;
e6h: approximately_equal (e6g, 0.0031 ` (1/nF), 0.00005));
true;
+/* maxima-discuss 2026-06-01, "Solving Equation with Ezunits Problem" */
+
+(R_1: 1 `kOhm,
+ R_2: 100 `Ohm,
+ V_1: 10 `V,
+ I: 3/2 `mA,
+ expr: V_1 = (R_1 + R_2) * I + V_2);
+10 ` V=V_2+(3/2 ` mA)*(100 ` Ohm+1 ` kOhm);
+
+foo1: solve(expr, V_2)[1];
+V_2=10 ` V+-(3/2) ` kOhm*mA+-150 ` Ohm*mA;
+
+rhs(foo1) ``V;
+167/20 ` V;
+
+foo2: dimensionally(solve(expr, V_2))[1];
+V_2 = -((300 ` Ohm*mA+3 ` kOhm*mA+(-20) ` V)/2);
+
+rhs(foo2) ``V;
+167/20 ` V;
-----------------------------------------------------------------------
Summary of changes:
share/ezunits/ezunits_functions.mac | 4 ++--
share/ezunits/rtest_ezunits_mroz_examples.mac | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
hooks/post-receive
--
Maxima CAS
|