gap> V:=GF(3)^3; ( GF(3)^3 ) gap> ## look at what GAP knows about vector spaces over finite fields gap> KnownAttributesOfObject(V); [ "LeftActingDomain", "DimensionOfVectors" ] gap> ## it should have a canonical basis gap> basis:=CanonicalBasis(V); CanonicalBasis( ( GF(3)^3 ) ) gap> ## a basis in GAP is more than a list, but its elements can be accessed as from a list gap> basis[1]; [ Z(3)^0, 0*Z(3), 0*Z(3) ] gap> ## can express vectors as linear combinations of basis elements gap> w:=Random( V ); [ 0*Z(3), 0*Z(3), Z(3) ] gap> coeffs:=Coefficients(basis,w); [ 0*Z(3), 0*Z(3), Z(3) ] gap> w:=Random( V ); [ Z(3), Z(3)^0, Z(3) ] gap> coeffs:=Coefficients(basis,w); [ Z(3), Z(3)^0, Z(3) ] gap> w = Sum( List( [1,2,3], i->coeffs[i]*basis[i] ) ); true gap> ## can also create your own bases gap> w1:=Random(V); w2:=Random(V); w3:=Random(V); [ 0*Z(3), 0*Z(3), Z(3) ] [ Z(3)^0, Z(3), Z(3)^0 ] [ Z(3), Z(3), 0*Z(3) ] gap> ## there's a good chance they're linearly independent gap> nbasis:=Basis(V,[w1,w2,w3]); Basis( ( GF(3)^3 ), [ [ 0*Z(3), 0*Z(3), Z(3) ], [ Z(3)^0, Z(3), Z(3)^0 ], [ Z(3), Z(3), 0*Z(3) ] ] ) gap> ## now express w in terms of the new basis gap> coeffs:=Coefficients(nbasis,w); [ 0*Z(3), Z(3), 0*Z(3) ] gap> w = Sum( List( [1,2,3], i->coeffs[i]*nbasis[i] ) ); true gap> ## another useful command can give you a corresponding vector of integers gap> IntVecFFE( w ); [ 2, 1, 2 ] gap> ## it's also worth noting the you can work easily with finite fields as vector spaces over the prime field gap> F:=GF( 3^3 ); GF(3^3) gap> KnownAttributesOfObject( F ); [ "Size", "Characteristic", "LeftActingDomain", "MultiplicativeNeutralElement", "GeneratorsOfRing", "GeneratorsOfRingWithOne", "Dimension", "DegreeOverPrimeField", "GeneratorsOfDivisionRing", "PrimitiveRoot" ] gap> ## we make a canonical basis for F over its prime field gap> K:=PrimeField( F ); GF(3) gap> V:=AsVectorSpace( F , K ); fail gap> V:=AsVectorSpace( K , F ); GF(3^3) gap> KnownAttributesOfObject( V ); [ "Size", "Characteristic", "LeftActingDomain", "MultiplicativeNeutralElement", "GeneratorsOfRing", "GeneratorsOfRingWithOne", "Dimension", "PrimeField", "DegreeOverPrimeField", "GeneratorsOfDivisionRing", "PrimitiveRoot" ] gap> r:=PrimitiveRoot(V); Z(3^3) gap> basis:=Basis( V , [r^0,r,r^2] ); Basis( GF(3^3), [ Z(3)^0, Z(3^3), Z(3^3)^2 ] ) gap> s:=Random( V ); Z(3^3)^24 gap> coeffs:=Coefficients( basis , s ); [ Z(3)^0, Z(3), Z(3) ] gap> s = Sum(List( [1,2,3], i->coeffs[i]*basis[i] )); true gap> OutputLogTo();