Skip to content

A 1x1 matrix has a rank and row echelon forms - #2272

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-one-by-one-matrix-has-a-rank
Oct 31, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-one-by-one-matrix-has-a-rank

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

For a 1x1 matrix, Rank, RowEchelonForm and ReducedRowEchelonForm threw InvalidCastException, and so did MathS.Matrices.PointwiseMultiplication of two 1x1 matrices. A 1x1 matrix simplifies to its entry, and each cast the simplified result back to Matrix.

Entity.Matrix.OfTheShapeOf wraps the entry back, but only when the source is 1x1. A larger matrix simplifies to something other than a matrix only when an entry has no value, as in #2270, and that case still throws: wrapping a NaN as a 1x1 matrix would give it a rank of 1.

Input 2.6.0 Now
[[2]].Rank throws 1
[[2]].ReducedRowEchelonForm throws [1]
[[0]].Rank throws 0
PointwiseMultiplication([[2]], [[3]]) throws [6]

OneByOneMatrixTest: 5 of its cases fail on master. The suite (18,234), the trio, F#, AOT and the eight harnesses pass locally. All 88 findings in work/matrixcheck were this bug.

Fixes #2269.

🤖 Generated with Claude Code

Rank, RowEchelonForm and ReducedRowEchelonForm threw
InvalidCastException for every 1x1 matrix, and so did
PointwiseMultiplication of two. A 1x1 matrix simplifies to its entry,
and each cast the simplified matrix back to Matrix.

OfTheShapeOf wraps the entry back for a 1x1 source only. A larger
matrix simplifies to something that is not a matrix only where an
entry has no value. That is #2270's NaN, and it still raises: wrapping
it as a 1x1 matrix would give that matrix a rank of 1.

OneByOneMatrixTest takes the rank and both forms of [2], [1/2], [-3]
and [0], and a pointwise product. Five cases fail on master. The suite,
the trio, F#, AOT and the eight harnesses pass. work/matrixcheck's 88
findings were all this.

Fixes #2269.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Oct 30, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.72%. Comparing base (ca785d3) to head (9bf2c40).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...rces/AngouriMath/Core/Entity/Omni/Entity.Matrix.cs 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2272   +/-   ##
=======================================
  Coverage   86.72%   86.72%           
=======================================
  Files         310      310           
  Lines       67833    67844   +11     
  Branches    19685    19690    +5     
=======================================
+ Hits        58826    58838   +12     
+ Misses       4890     4889    -1     
  Partials     4117     4117           
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.27% <83.33%> (+<0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

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

Files with missing lines Coverage Δ
Sources/AngouriMath/Convenience/MathS.cs 90.49% <100.00%> (ø)
...rces/AngouriMath/Core/Entity/Omni/Entity.Matrix.cs 83.40% <80.00%> (-0.21%) ⬇️

... 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 f570b35 into master Oct 31, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 31, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-one-by-one-matrix-has-a-rank branch October 31, 2026 00:06
Rafael-SOWNet added a commit that referenced this pull request Oct 31, 2026
#2272 wraps both forms' simplified matrix in OfTheShapeOf, and this
branch moves both to the Simple elimination; each form now does both.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

Rank and the row echelon forms of a 1x1 matrix throw InvalidCastException

1 participant