# [GAP Forum] bases of vector spaces

Thomas Breuer thomas.breuer at math.rwth-aachen.de
Thu Sep 2 09:06:04 BST 2004

```Dear GAP Forum,

Laurent Bartholdi wrote

> hi,
> this is maybe not a bug, but seems very strange behaviour to me:
>
> gap> GF(2)^100;
> ( GF(2)^100 )
> gap> Basis(last);
> CanonicalBasis( ( GF(2)^100 ) )
> gap> VectorSpace(GF(2),last);
> <vector space over GF(2), with 100 generators>
> gap> Basis(last);
> SemiEchelonBasis( <vector space over GF(2), with 100 generators>, ...=
>  )
> gap> VectorSpace(GF(2),last);
> <vector space over GF(2), with 100 generators>
> gap> Basis(last);
> Basis( <vector space over GF(2), with 100 generators>, ... )
> gap> VectorSpace(GF(2),last);
> user interrupt at
> i :=3D i + 1;
> =2E..
> and GAP runs till it exhausts memory. if instead of
> VectorSpace(GF(2),last) i used VectorSpace(GF(2),Elements(last)) ther=
> e is
> no problem.
>
> best, laurent

Sure this is a bug.

And this is the problem behind the message.

gap> v1:= GF(2)^100;;  b1:= Basis( v1 );
CanonicalBasis( ( GF(2)^100 ) )
gap> IsMatrix( b1 );
true
gap> v2:= VectorSpace( GF(2), b1 );;  b2:= Basis( v2 );
SemiEchelonBasis( <vector space over GF(2), with 100 generators>, ... )
gap> IsMatrix( b2 );
false

The method that is used to create the basis `b2' did not store
that the basis is a matrix.
This information would be needed for the creation of the next
vector space.

This bug will be fixed with the next bugfix.
For the moment, reading the following piece of code
will help.

InstallMethod( SemiEchelonBasis,
"for Gaussian row space",
[ IsGaussianRowSpace ],
function( V )
local B, gens;

B:= Objectify( NewType( FamilyObj( V ),
IsFiniteBasisDefault
and IsSemiEchelonized
and IsSemiEchelonBasisOfGaussianRowSpaceRep ),
rec() );

gens:= GeneratorsOfLeftModule( V );
if IsEmpty( gens ) or ForAll( gens, IsZero ) then
SetIsEmpty( B, true );
else
SetIsRectangularTable( B, true );
fi;

SetUnderlyingLeftModule( B, V );
return B;
end );

All the best,
Thomas

```