# 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

What is "XOR between matrix space"?

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.