# 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[0], 1: B[1], 2: B[2], 3: B[3]}

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

What is "XOR between matrix space"?

( 2022-02-07 20:43:52 +0200 )edit

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.

( 2022-02-08 18:05:40 +0200 )edit

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.

( 2022-02-08 18:08:12 +0200 )edit

I assume you need to use .retract() method. See details in the docs.

( 2022-02-08 19:47:38 +0200 )edit