# span of matrices over finite fields

Hello,

I'd to build the span of some matrices defined over GF(4). However, the function span doesn't fit since it seems to interpret matrices as lists of vectors. I tried the following :

F=GF(4);
n=11;
A=random_matrix(F,n);
B=random_matrix(F,n);
print(span(A,F));
print(span([A,B],F));


None of which gives satisfying results (the second one gives an error). So, I wanted to know if there was a way to properly get a span of matrices in sagemath.

edit retag close merge delete

Sort by » oldest newest most voted

The issue is that matrices are not considered as vectors, so you can flatten them as vectors first:

sage: S = span([vector(A),vector(B)]) ; S
Vector space of degree 121 and dimension 2 over Finite Field in z2 of size 2^2
Basis matrix:
2 x 121 dense matrix over Finite Field in z2 of size 2^2


Given a vector v in such a space, you can make it a matrix as follows:

sage: v = S.random_element()
sage: matrix(n,n,v)


You can check consistency:

sage: matrix(n,n,vector(A)) == A
True
sage: matrix(n,n,vector(B)) == B
True
sage: v in S
True
sage: vector(A) in S
True

more