# How to construct a matrix space ?

I know we can create a matrix space using "MatrixSpace" but I am looking to create a specific space. I tried :

M = MatrixSpace(ZZ,4)
B = M.basis()
sub = [B[0,0],B[1,3],B[2,2],B[3,1]]
SubM = M.submodule(sub)
SubM.basis()


The program show me : Finite family {0: B, 1: B, 2: B, 3: B}

And when I take a random element of SubM( with SubM.random_element()), it tells me it isn't in M.

I thought the problem came from my generator so I tried with :

sub = [matrix(4,4,{(0,0):1}),matrix(4,4,{(1,3):1}),matrix(4,4,{(2,2):1}),matrix(4,4,{(3,1):1})]

But I have the same result. Do you know what I am doing wrong ?

I also need to do a XOR between matrix space, do you think it is possible ? How ?

Thanks you for your time :D

edit retag close merge delete

it is not really explained but I guess that it is a matrix space which have as element the xor of elements of 2 matrix spaces.

Sort by » oldest newest most voted

To see the basis of SubM as elements of M use

[b.lift() for b in SubM.basis()]


Similarly, to get a random element of SubM lifted to M run:

SubM.random_element().lift()

more

Thank you for your answer ! By chance, do you know how can I "reverse" .lift() ? When I create a matrix and try to check if it is in SubM, it always return false.