Repository navigation
Keep a transpose or a vector product beside a written matrix a matrix - #2560
Merged
Merged
Conversation
InnerSimplified and Evaled share ExpandOnTwoArguments, which spread any operand that was not a written matrix over a written matrix's entries. A transpose or a vector product not yet carried out was read as a number that way: [1, 0]T * transpose(A) * [0, 1] became [[transpose(A), 0]] * [0, 1] and so 0, where it is the entry A[2, 1], and [0, 0, 1]T * cross(a, b) became [[0, 0, cross(a, b)]], a row with a vector for an entry. Simplify set the plain product aside and kept it, but it sorted a product whose factor was a sum with a transpose in it as though matrices commuted, so [1, 0]T * (transpose(A) + B) * [0, 1] was 0 there too, and it spread [1, 0] + transpose(A) over the entries. ProductsOfMatrices.IsAMatrixNotWrittenOut now says what is such a matrix: a transpose or a vector product that simplification cannot carry out, or anything with one in it other than inside a determinant, a trace, an entry, a scalar product or a norm, a statement or a set. A function of one counts, since not knowing it to be a number is reason enough not to read it as one; abs is a vector's length and is taken entry by entry over a larger matrix. ExpandOnTwoArguments leaves such an operand beside a written matrix as written, and the three places that decide whether a product's factors may be sorted or set aside ask the same question, where each asked only about a bare transpose or vector product. A bare name is not counted: beside a written matrix it is read as a number, as x * [1, 2] is [x, 2 x], and [1, 0]T * A * [0, 1] is still 0. That is an older decision about names, which carry no type (#1237). Measured on v2.9.0 and on this branch; the table is in BREAKING-CHANGES. The 20 new tests fail on master and pass here. The whole UnitTests run: 21442 passed, 4 failed, and those 4 fail the same way on master on this Dutch-culture machine (two read 0,5 as two arguments, a documented example prints 0,4) or time out only inside the full parallel run (ln(x) * erf(x), which passes alone on both). F# wrapper tests 135/135. CanonCheck and Confluence match their baselines. Part of #2557. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2560 +/- ##
==========================================
+ Coverage 86.71% 86.72% +0.01%
==========================================
Files 344 344
Lines 74809 74836 +27
Branches 21821 21837 +16
==========================================
+ Hits 64868 64904 +36
+ Misses 5372 5363 -9
Partials 4569 4569
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…NGES entries Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rafael-SOWNet
added a commit
that referenced
this pull request
Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # BREAKING-CHANGES.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2557.
InnerSimplifiedandEvaledread a transpose that is not yet carried out as a number, so they multiplied it into the written vectors around it:[1, 0]T * transpose(A) * [0, 1]was0, where it is the entryA[2, 1].Simplifykept that product, but read a transpose inside a sum as a number, so[1, 0]T * (transpose(A) + B) * [0, 1]was0there too.What was wrong
Measured with
A = [[5, 6], [7, 8]],B = [[10, 20], [30, 40]]andx = 2substituted where a value is shown:[1, 0]T * transpose(A) * [0, 1],InnerSimplified07onceAis substituted[1, 0]T * transpose(A + [[1, 2], [3, 4]]) * [0, 1],InnerSimplified010onceAis substituted[1, 0]T * transpose(x * [[1, 2], [3, 4]]) * [0, 1],InnerSimplified06atx = 2[1, 0]T * (transpose(A) + B) * [0, 1],Simplify023once both are substituted[1, 0] + transpose(A),SimplifyThe full table, measured on the 2.9.0 package and on this branch, is the new BREAKING-CHANGES entry.
Why
InnerSimplifiedandEvaledgo throughExpandOnTwoArguments, which multiplies an operand that is not a written matrix into a written matrix's entries, so[1, 0]T * transpose(A)became[[transpose(A), 0]]. A vector product not yet carried out was read the same way.Simplifysets a product with a bare transpose in it aside (#1237, #2147), but took only a bare transpose or vector product for a matrix, so a transpose inside a sum or a product was sorted as if it commuted.How
ProductsOfMatrices.IsAMatrixNotWrittenOut. An expression is a matrix when it contains a transpose or a vector product that cannot be carried out yet. Occurrences inside a written matrix, adet, atrace, an entry, adot, a norm, a statement or a set do not count.ExpandOnTwoArgumentsleaves such an operand beside a written matrix as written.Simplifythat decide whether a product's factors may be reordered or set aside use the same test.x * [1, 2]is[x, 2 x], Typed variables #1237), so[1, 0]T * A * [0, 1]is still0. That is the older decision about names, which carry no type, and this PR does not change it.Tested
MatrixOperationNodesTestandDotAndCrossNodesTest, each compared with the value after substituting the matrices. They fail on master and pass here.0,4) and a timeout inside the full parallel run that passes alone. F# wrapper tests: 135 of 135. CanonCheck and Confluence match their committed baselines.Syntax.mdgained a sentence: a transpose beside a written matrix is not multiplied into its entries.Not in this PR
[1, 0]T * derivative(transpose(x * A), x) * [0, 1], withA = [[1, 2], [3, 4]]substituted, was a wrong0fromEvaled. It is now left unevaluated, where the answer is3: the derivative leaves[[0, 0], [0, 0]] * xinside the transpose, and the caution about a name beside a written matrix keeps the transpose from being carried out.transpose(A) * 0is still the number0rather than a zero matrix, an older convention.Merging with the compiler PR for
dotandcross: both add an entry at the end of "Unreleased" in BREAKING-CHANGES; keep both. Nothing else overlaps.🤖 Generated with Claude Code