-
Notifications
You must be signed in to change notification settings - Fork 184
Improve BaseDomain for plist-of-list matrices #4805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| gap> START_TEST("BaseDomain.tst"); | ||
|
|
||
| # | ||
| gap> m := [[1,2],[3,4]];; | ||
| gap> BaseDomain(m); | ||
| Rationals | ||
| gap> BaseDomain(Matrix(m)); | ||
| Rationals | ||
| gap> BaseDomain(Matrix(Rationals, m)); | ||
| Rationals | ||
| gap> BaseDomain(Matrix(Integers, m)); | ||
| Integers | ||
|
|
||
| # FIXME: BUG: | ||
| #gap> BaseDomain(Matrix(GF(2), m)); | ||
| #Rationals | ||
|
|
||
| # | ||
| gap> m := [[1,2],[3,4/3]];; | ||
| gap> BaseDomain(m); | ||
| Rationals | ||
| gap> BaseDomain(Matrix(m)); | ||
| Rationals | ||
| gap> BaseDomain(Matrix(Rationals, m)); | ||
| Rationals | ||
|
|
||
| # FIXME: BUG: | ||
| # gap> BaseDomain(Matrix(Integers, m)); | ||
| #Integers | ||
| #gap> BaseDomain(Matrix(GF(2), m)); | ||
| #Rationals | ||
|
|
||
| # | ||
| gap> m := [[1,2],[3,4]] * Z(2);; | ||
| gap> BaseDomain(m); | ||
| GF(2) | ||
| gap> BaseDomain(Matrix(m)); | ||
| GF(2) | ||
| gap> BaseDomain(Matrix(GF(2), m)); | ||
| GF(2) | ||
|
|
||
| # FIXME: BUG: | ||
| #gap> BaseDomain(Matrix(Rationals, m)); | ||
| #Rationals | ||
|
|
||
| # | ||
| gap> m := [[1,2],[3,Z(4)]] * Z(2);; | ||
| gap> BaseDomain(m); | ||
| GF(2^2) | ||
| gap> BaseDomain(Matrix(m)); | ||
| GF(2^2) | ||
| gap> BaseDomain(Matrix(GF(4), m)); | ||
| GF(2^2) | ||
| gap> BaseDomain(Matrix(GF(2), m)); | ||
| Error, ConvertToVectorRepNC: Vector cannot be written over GF(2) | ||
|
|
||
| # FIXME: BUG: | ||
| #gap> BaseDomain(Matrix(Rationals, m)); | ||
| #Rationals | ||
|
|
||
| # | ||
| gap> STOP_TEST("BaseDomain.tst"); | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,4 +18,3 @@ gap> List( res2[2], r -> [ r.field, r.dimension ] ); | |
|
|
||
| # | ||
| gap> STOP_TEST( "grpreps.tst" ); | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently
Matrix(GF(2), m)returns a copy ofm.The
NewMatrixmethod in question callsConvertToMatrixRepand ignores thefailresult.I think this method should signal an error.
(Well, we should first agree that we want an error message here.
The documentation states that the matrix entries need not lie in the base ring of the matrix but may also "naturally embed in the sense that addition and multiplication automatically work with elements of the base domain".
The condition about arithmetic operations is satisfied for integers and elements of GF(2) but we are not in the situation of an embedding; perhaps the documentation should be made more precise here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that wording was specifically there based on discussion with @frankluebeck, to allow having entries equal to immediate integer objects like 0 and 1, which are much more efficient than general ring elements. I.e. this was strictly intended for optimization purposes.
However, I always felt this is "iffy", and I would reject it for this constructor. Of course a matrix type may use integer objects internally, to fill entries (as, indeed, the new matrix type over Z/nZ defined by @hulpke does); and the implementor may also provide special constructors which accept as input such immediate integers (and anything else that they see fit), but IMHO the default methods should not be required to do so...
Of course checking whether elements are inside a given domain can be expensive. So perhaps we'd want a (set of)
MatrixNCmethods which don't perform these checks (and/or a "nocheck" option, or whatever). But arguably the default ways to construct MatrixObj instances should IMHO reject "obvious" nonsense.