I am trying to make a dictionary of matrices. Ideally
MatDic={
matrix(GF(2),2,[1,0,0,1]):'a',
matrix(GF(2),2,[1,1,0,1]):'b'
# etc
}
But Sage refuses to hash (mutable) matrices. I then tried
MatDic={
matrix(GF(2),2,[1,0,0,1]).set_immutable():'a',
matrix(GF(2),2,[1,1,0,1]).set_immutable():'b'
}
MatDic
which gives
{None: 'b'}
I also tried making a dictionary of tuples
MatDic={
(1,0,0,1):'a',
(1,1,0,1):'b'
}
which raises no errors; However
MatDic[tuple(matrix(GF(2),2,[1,0,0,1]))]
gives
TypeError: mutable vectors are unhashable
What is the best, if possible, way to make a dictionary and lookup matrices?