# Matrices not equal, but entries are. Why?

Hi,

I've created a class which derives from RingElement and a class which derives from Ring, and made the latter the parent of the former. I have then placed the "elements" of this new ring I've constructed as entries into a matrix.

Given another such matrix with the same dimensions as the first, I have constructed its entries to be the same as the entries of the first matrix. The same means that when we compare entry (i,j) in the first matrix to entry (i,j) in the second, they are equal.

Why do the matrices not compare as equal? Is there anything you see in this error which could help me easily remedy this?

Here is the error I get:

```
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "_sage_input_58.py", line 10, in
> <module>
> exec compile(u'open("___code___.py","w").write("#
> -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dnYgPSBtYXRyaXhfY2xlYW5lZF91cF9yZWR1Y3Rpb24oQV9BQikKQV9BQiA9PSBtYXRyaXhfY2xlYW5lZF91cF9yZWR1Y3Rpb24oQV9BQikuZ2V0X21hdHJpeF9BKCk="),globals())+"\\n");
> execfile(os.path.abspath("___code___.py"))
> File "", line 1, in <module>
> File "/tmp/tmplS8fJ8/___code___.py", line
> 3, in <module>
> exec compile(u'A_AB == matrix_cleaned_up_reduction(A_AB).get_matrix_A()
> File "", line 1, in <module>
> File "matrix_generic_dense.pyx", line 167,
> in
> sage.matrix.matrix_generic_dense.Matrix_generic_dense.__richcmp__
> (sage/matrix/matrix_generic_dense.c:3036)
> File "element.pyx", line 876, in
> sage.structure.element.Element._richcmp
> (sage/structure/element.c:8370) File
> "element.pyx", line 923, in
> sage.structure.element.Element._richcmp_c_impl
> (sage/structure/element.c:8671) File
> "matrix_dense.pyx", line 126, in
> sage.matrix.matrix_dense.Matrix_dense._cmp_c_impl
> (sage/matrix/matrix_dense.c:2757)
> File "element.pyx", line 913, in
> sage.structure.element.Element.__cmp__
> (sage/structure/element.c:8541) File
> "element.pyx", line 809, in
> sage.structure.element.Element._cmp
> (sage/structure/element.c:7239) File
> "coerce.pyx", line 880, in
> sage.structure.coerce.CoercionModel_cache_maps.canonical_coercion
> (sage/structure/coerce.c:8296) File
> "coerce.pyx", line 1419, in
> sage.structure.coerce.CoercionModel_cache_maps._coercion_error
> (sage/structure/coerce.c:14011)
> RuntimeError: There is a bug in the
> coercion code in Sage. Both x
> (=[((((1)(2)(3)(4), _, {{1}}, {{2},
> {1}}, {{2}, {3}, {1}}), {}), ())]) and
> y (=[((((1)(2)(3)(4), _, {{1}}, {{2},
> {1}}, {{2}, {3}, {1}}), {}), ())]) are
> supposed to have identical parents but
> they don't. In fact, x has parent
> 'Combinatorial Scalar Ring' whereas y
> has parent 'Combinatorial Scalar Ring'
> Original elements [((((1)(2)(3)(4), _,
> {{1}}, {{2}, {1}}, {{2}, {3}, {1}}),
> {}), ())] (parent Combinatorial Scalar
> Ring) and [((((1)(2)(3)(4), _, {{1}},
> {{2}, {1}}, {{2}, {3}, {1}}), {}),
> ())] (parent Combinatorial Scalar
> Ring) and maps <type 'NoneType'> None
> <type
> 'sage.structure.coerce_maps.DefaultConvertMap_unique'>
> Conversion map: From: Combinatorial
> Scalar Ring To: Combinatorial
> Scalar Ring
```

The message seems to indicate that there was a problem coercing entries of the two matrices in question into the same ring. By construction, it appears that the rings are identical, but perhaps that hasn't been told to the coercion framework?