Skip to content

Add IsSquareMat and IsAntisymmetricMat#6268

Open
limakzi wants to merge 5 commits intogap-system:masterfrom
limakzi:6264-add-issquare
Open

Add IsSquareMat and IsAntisymmetricMat#6268
limakzi wants to merge 5 commits intogap-system:masterfrom
limakzi:6264-add-issquare

Conversation

@limakzi
Copy link
Copy Markdown
Member

@limakzi limakzi commented Mar 12, 2026

Add IsSquareMatrix/IsSquareMat to check whether a matrix is square.
Add IsAntisymmetricMatrix/IsAntisymmetricMat to check whether mat[i,j] = -mat[j,i] for all entries.

Both symmetric and antisymmetric matrices imply IsSquareMatrix via InstallTrueMethod. IsSymmetricMatrix is simplified to use IsSquareMatrix instead of an inline dimension check.

Fixes #6264.

Copilot AI review requested due to automatic review settings March 12, 2026 22:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds new matrix properties to the matrix subsystem, improving reuse and consistency across related predicates.

Changes:

  • Introduces IsSquareMatrix / IsSquareMat and adds test coverage for square vs. non-square matrices.
  • Introduces IsAntisymmetricMatrix / IsAntisymmetricMat (with documentation and tests).
  • Refactors IsSymmetricMatrix to use IsSquareMatrix, and installs implications that symmetric/antisymmetric matrices are square.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tst/testinstall/matrix.tst Adds tests for IsSquareMat and IsAntisymmetricMat.
lib/matrix.gi Implements IsSquareMatrix and IsAntisymmetricMatrix; simplifies IsSymmetricMatrix square-check.
lib/matrix.gd Declares new properties/synonyms, adds GAPDoc entries, and installs implications to IsSquareMatrix.
doc/ref/matrix.xml Includes the new GAPDoc sections in the reference manual.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@fingolfin fingolfin changed the title Add IsSquareMat and IsAntisymmetricMat Add IsSquareMat and IsAntisymmetricMat Mar 18, 2026
lib/matrix.gi Outdated
@@ -274,6 +288,35 @@ InstallMethod( IsSymmetricMatrix,
InstallTrueMethod( IsSymmetricMatrix, IsMatrixOrMatrixObj and IsEmptyMatrix );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also go, and tests be added.

Luckily, it doesn't actually work for e.g. IsPlistMatrixRep (not sure why, but I also did not try to investigate).

But the following could also be basis for a test.

gap> a := NewZeroMatrix(IsPlistMatrixRep, Integers, 0, 2);
<0x2-matrix over Integers>
gap> b := NewZeroMatrix(IsPlistMatrixRep, Integers, 2, 0);
<2x0-matrix over Integers>
gap> c := NewZeroMatrix(IsPlistMatrixRep, Integers, 0, 0);
<0x0-matrix over Integers>
gap>
gap> IsEmptyMatrix(a);
true
gap> IsEmptyMatrix(b);
true
gap> IsEmptyMatrix(c);
true
gap>
gap> IsSymmetricMatrix(a);
false
gap> IsSymmetricMatrix(b);
false
gap> IsSymmetricMatrix(c);
true

@fingolfin
Copy link
Copy Markdown
Member

I've applied my suggestions and added a bunch of test with "empty" matrices / MatrixObj

@fingolfin fingolfin added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements topic: library release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Mar 23, 2026
@fingolfin
Copy link
Copy Markdown
Member

Fails because the HAPcryst package also defines DeclareProperty("IsSquareMat",IsMatrix); (which is fine) with a really bad method:

InstallMethod(IsSquareMat,"for matrices",[IsMatrix],
        function(mat)
        return Size(Set(mat,Size))=1;
end);

@fingolfin
Copy link
Copy Markdown
Member

See gap-packages/hapcryst#12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add IsSquareMat / IsAntisymmetricMat

4 participants