Commit a2fd057
fix(simplify): Array and object simplification (#2382)
* fix(simplify): Allow simplify to work in arrays, objects, and indexing
Mostly ArrayNode, ObjectNode, AccessorNode, and IndexNode nodes are
simply transparent to simplification -- they simply allow it to occur
within subexpressions. Then main exception is that if an array or object
is indexed by a constant, the expression can be replaced by the
corresponding subitem, e.g. `[3,4,5][2]` simplifies to `4`.
This at least partially resolves #1913 (see my latest comment there).
* fix(simplify): Resolve operations on constant arrays
This involves allowing ArrayNodes containing only constant entries
to temporarily convert to Matrix type inside of simplifyConstant, so that
function and operator calls can occur on them.
I also had to add a special case for the function `size` because
it can be computed even on symbolic arrays, since the result depends
only on the shape, not the entries.
Deals with additional cases of #1913; unclear if there are remaining
aspects of that issue on which further work is desirable.
* chore: fix alphabetization of dependencies
And restores inadvertent deletion of a blank line.
Co-authored-by: Jos de Jong <[email protected]>1 parent 84c3abd commit a2fd057
File tree
5 files changed
+290
-51
lines changed- src/function/algebra
- simplify
- test/unit-tests/function/algebra
5 files changed
+290
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | | - | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | | - | |
48 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
| 64 | + | |
56 | 65 | | |
57 | 66 | | |
| 67 | + | |
58 | 68 | | |
59 | 69 | | |
60 | | - | |
61 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
| |||
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
| 84 | + | |
| 85 | + | |
72 | 86 | | |
73 | | - | |
74 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
75 | 91 | | |
76 | 92 | | |
77 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
| 68 | + | |
60 | 69 | | |
61 | 70 | | |
| 71 | + | |
62 | 72 | | |
63 | 73 | | |
64 | | - | |
65 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
66 | 78 | | |
67 | 79 | | |
68 | 80 | | |
| |||
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
| 88 | + | |
| 89 | + | |
76 | 90 | | |
77 | | - | |
78 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| |||
418 | 434 | | |
419 | 435 | | |
420 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
421 | 445 | | |
422 | 446 | | |
423 | 447 | | |
| |||
432 | 456 | | |
433 | 457 | | |
434 | 458 | | |
435 | | - | |
436 | | - | |
| 459 | + | |
| 460 | + | |
437 | 461 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
| 462 | + | |
443 | 463 | | |
444 | 464 | | |
445 | 465 | | |
446 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
447 | 482 | | |
448 | 483 | | |
449 | 484 | | |
| |||
0 commit comments