Fix a bug when calculating GModMat