Dear Gap Forum,
Andrea Previtali wrote
I defined a vector space V generated by a list of independent matrices and
would like them to be its basis. The few examples I worked out always
confirmed that the list used to define V coincides with the list generated
by the command Base.
is that really always the case?
Yes, for a vector space of matrices (in GAP 3),
a basis computed with `Base' consists of a subset of the
generators of the vector space.
Set ba:=Base(V) (by the way, I noticed that Basis(V) is not recognized).
Trying to determine the Coefficients of v in V wrt ba as
Coefficients(ba,v), I got an error message, and trying with
Coefficients(V,v) I get a list containing scalars AND the zero matrix in
Is there a way to get only scalars?
I cannot reproduce the erroneous behaviour of `Coefficients'.
For example, the following works.
gap> v:= VectorSpace( [ IdentityMat( 3, GF(2) ) ], GF(2) );; gap> Coefficients( v, v.generators ); [ Z(2)^0 ]
It should be noted, however, that the only vector spaces that are handled
efficiently in GAP 3 are row spaces.
For example, no bases can be computed for nontrivial vector spaces
of matrices over infinite fields.
And also the (correct) `Coefficients' call with first argument a basis
is implemented only for row spaces.
So it may be a good idea to deal with the matrix spaces implicitly,
that is, construct a vector space generated by the row vectors obtained
by concatenating the rows of each matrix, form the interesting bases
of this row space, and then compute the coefficients w.r.t. this basis
for the concatenation of the matrix in question.
Here is an example:
gap> m1:= [ [ 1, 0 ], [ 0, 1 ] ];; gap> m2:= [ [ 1, 1 ], [ 1, 0 ] ];; gap> v:= VectorSpace( [ m1, m2 ], Rationals ); VectorSpace( [ [ [ 1, 0 ], [ 0, 1 ] ], [ [ 1, 1 ], [ 1, 0 ] ] ], Rationals ) gap> m1 in v; Error, sorry, cannot test if <d> lies in the infinite domain <D> in <elm> in <rec> called from main loop brk> quit; gap> r:= VectorSpace( List( [ m1, m2 ], Concatenation ), Rationals ); RowSpace( Rationals, [ [ 1, 0, 0, 1 ], [ 1, 1, 1, 0 ] ] ) gap> Concatenation( m1 ) in r; true gap> b:= Basis( r, List( [ m1, m2 ], Concatenation ) ); Basis( RowSpace( Rationals, [ [ 1, 0, 0, 1 ], [ 1, 1, 1, 0 ] ] ), [ [ 1, 0, 0, 1 ], [ 1, 1, 1, 0 ] ] ) gap> Coefficients( b, Concatenation( m1 + m2 ) ); [ 1, 1 ]
Sorry that the handling of vector spaces other than row spaces
requires such explicit translations in GAP 3.
The forthcoming version 4 of GAP will be able to deal with (bases of)
vector spaces of matrices (and several other kinds of elements) directly,
either by special methods or (implicitly) by the mechanism described above.