Skip to content

Make the trace of a matrix that is not square null - #2572

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
trace-of-a-square-matrix-only
Nov 26, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
trace-of-a-square-matrix-only

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #2565.

Matrix.Trace summed the main diagonal of any matrix, so [[1, 2, 3], [4, 5, 6]] had the trace 1 + 5, and the vector [1, 2, 3] the trace 1. trace(...) refused both. The trace is defined for a square matrix only, as the sum of its eigenvalues.

The property is now Entity?, null for a matrix that is not square, as Determinant, Inverse and Adjugate are. The parser and the evaluation of trace(...) now match on the value instead of checking the shape first. The internal catalogue query is typed to match, and the MCP tool already handled a null.

2.9.0 this branch
((Matrix)"[[1, 2, 3], [4, 5, 6]]").Trace 1 + 5 null
((Matrix)"[1, 2, 3]").Trace 1 null
((Matrix)"[[1, 2], [3, 4]]").Trace 1 + 4 unchanged
"trace([[1, 2], [3, 4]])" 1 + 4 unchanged

Local checks:

  • the suite: 21,511 passed;
  • the MCP, Terminal, Interactive and F# suites;
  • AOT: 83 passed, and the smoke test published with AngouriMathPublishAot=true;
  • all nine harnesses, with canoncheck, confluence and the Modenov corpus matching their baselines;
  • the solver cross-checks and scalecheck: identical to master except timings.

🤖 Generated with Claude Code

Matrix.Trace summed the main diagonal of any matrix, so [[1, 2, 3], [4, 5, 6]]
had the trace 1 + 5 and [1, 2, 3] the trace 1, while trace(...) refused both:
the trace is defined for a square matrix, as the sum of its eigenvalues. It is
Entity? now, null for any other matrix, as Determinant, Inverse and Adjugate
are. The parser and the evaluation of trace(...) match on the value instead of
checking the shape first, and the catalogue query is typed to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.73%. Comparing base (482e3e5) to head (bd4e2a8).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2572   +/-   ##
=======================================
  Coverage   86.73%   86.73%           
=======================================
  Files         344      344           
  Lines       74833    74833           
  Branches    21837    21838    +1     
=======================================
  Hits        64905    64905           
+ Misses       5361     5360    -1     
- Partials     4567     4568    +1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.23% <100.00%> (ø)
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Sources/AngouriMath/Core/Antlr/ParsingHelpers.cs 92.85% <100.00%> (ø)
...rces/AngouriMath/Core/Entity/Omni/Entity.Matrix.cs 85.25% <100.00%> (ø)
...ore/Entity/Omni/Entity.MatrixOperations.Classes.cs 100.00% <ø> (ø)
Sources/AngouriMath/Core/Operations/Catalogue.cs 100.00% <100.00%> (ø)
...luation/Evaluation.Omni/Evaluation.Omni.Classes.cs 87.33% <100.00%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit 4faf113 into master Nov 26, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 26, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the trace-of-a-square-matrix-only branch November 26, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Matrix.Trace of a non-square matrix is a number, where trace(...) refuses it

1 participant