Commit f3cab22
committed
Fix #354: t2s constant_mul keeps a symbolic scalar_wrapper factor
constant_mul::dispatch(tensor_to_scalar_mul) handled a numeric LHS by
merging it into the coefficient, but a non-numeric scalar_wrapper LHS
fell through the same path: the factor was never inserted and the
coefficient was reset to the wrapped default, so
wrapper(x) * (trace(A)*det(A)) evaluated as if x were 1. The promoted
route (plain x * (f*g)) goes through mul_base and was correct, which
is why tests missed it - the bug fires whenever the wrapper is the
visitor's LHS.
Non-numeric wrappers are now inserted as factors via push_or_combine
(merging with an existing wrapper child through the unwrap-multiply-
rewrap path).
Signed-off-by: petlenz <peterlenz89.pl@gmail.com>1 parent e5ca023 commit f3cab22
2 files changed
Lines changed: 26 additions & 3 deletions
File tree
- src/numsim_cas/tensor_to_scalar/simplifier
- tests
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
| 48 | + | |
| 49 | + | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
924 | 940 | | |
0 commit comments