# How to make the product of two linear spaces?

Let $F_{q^m}$ be a finite field that is the extension of degree m of a finite field $F_q$. r<m, d<m.<="" p="">

E1 is an $F_q$-linear space of dimension r of $F_{q^m}$.

E2 is an $F_q$-linear space of dimension d of $F_{q^m}$.

How to fastly obtain the product of E1 and E2?

edit retag close merge delete

No cartesian_product. I only know this method with poor efficiency. Do you have other efficient methods?

q = 2 ; m = 229; n = 83; r = 8; d= 7

Fqm = GF(q^m)

def gen_vec_space(t): # generate a vector space of dimension t over Fqm

B = matrix(Fqm.base_ring(),t,m,0)

while B.rank() != t:

B = matrix(Fqm.base_ring(),[vector(Fqm.random_element()) for i in range(t)])

return B.row_space()


E = gen_vec_space(r)

F = gen_vec_space(d)

def two_spaces_product(T1, T2):

T1T2 = []

for e in T1.basis():

for f in T2.basis():

T1T2.append(vec_to_Fqm(e) * vec_to_Fqm(f))

ST1T2 = matrix(Fqm.base_ring(),[vector(T1T2[i]) for i in range(len(T1T2))]).row_space()

return ST1T2


EF = two_spaces_product(E,F)

I don't understand why cartesian_product doesn't do what you want. Can you please explain?