List vs. Filtered #5693
-
I have discovered a somewhat unexpected behavior. If I create a vector space with an immutable (as in |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I am not actually sure what you mean by that; please consider posting actual code (snippets) along with your questions, that will clarify what you mean and avoid confusion. So here are some general remarks: In GAP, historically matrices were implemented as lists-of-lists. This is why functions like This list-of-lists approach at first seems neat and elegant, but it has many serious downsides. To address this for finite fields, "compressed matrices" were invented which try to be better matrices than plain lists of lists -- but at heart they still are lists of (row) vectors. Some tools then recognize their input is a compressed matrix and try to produce an output that is, too, but not all do (and not for all would it even make sense). The It is not clear to me how yo uget from "a basis of Fgap> V:=GF(2)^5;
( GF(2)^5 )
gap> B:=Basis(V);
CanonicalBasis( ( GF(2)^5 ) )
gap> C:=Filtered(B, v -> IsZero(v[1]));
[ <an immutable GF2 vector of length 5>, <an immutable GF2 vector of length 5>,
<an immutable GF2 vector of length 5>, <an immutable GF2 vector of length 5> ] This does not involve any immutable matrices. Though if I really wanted to, I could turn list list of four vectors into a "compressed matrix" (which after all is just a special kind of lists anyway): gap> ConvertToMatrixRep(C);
2
gap> C;
<a 4x5 matrix over GF2> |
Beta Was this translation helpful? Give feedback.
-
Apparently, my installation is either way too outdated or broken. What I get is
and it is this behavior that I reported as inconsistent. In fact, it took me quite a while to figure out why one approach is much slower than the other. Accidentally, do I take it right from the manual that |
Beta Was this translation helpful? Give feedback.
-
OK, thanks. I agree that GAP never guarantees a particular representation of the output (unless it's a representation conversion function), and this makes perfect sense and increases the flexibility, but still it's a bit inconsistent. |
Beta Was this translation helpful? Give feedback.
I am not sure why you think any of this implies your installation is outdated or broken? I get the exact same output. Also note that nothing in that example involves immutable matrices either.
The root cause is that the code which implements iteration over vector spaces does not bother to return compressed vectors (possibly because it predates their invention). The function
Filtered
uses the iteration interface -- as doesList(coll, func)
. But there is a special methodList(vecspace)
it seems. Hence: