Fix a bug in __richcmp__ method for Matrix classes