1 | initial version |
You should mention what error you got. For creating all the 2x2 matrices over some finite field use the MatrixSpace class.
sage: M = MatrixSpace(GF(3), 2, 2)
sage: M
Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 3
sage: Mlist = M.list() # List containing all the matrices
sage: len(Mlist)
81
As for your function, it is also not correct, unless you have copy-pasted incorrectly.