Hi Jeroen! On Oct 6, 8:15 am, Jeroen Demeyer <[email protected]> wrote: > More precisely, I am looking for the location of the code which compares > a Matrix_modn_sparse with a Matrix_modn_dense. I.e. I want to see the > code for > > sage: L = matrix(GF(43), 3, 3, range(9), sparse=True) > sage: R = matrix(GF(43), 3, 3, range(9)) > sage: type(L) > <type 'sage.matrix.matrix_modn_sparse.Matrix_modn_sparse'> > sage: type(R) > <type 'sage.matrix.matrix_modn_dense.Matrix_modn_dense'> > sage: L==R # Where is this implemented? > True
If I am not mistaken, there is a generic __cmp__ (double underscore) method at work, that will first send both arguments to a common parent, by means of Sage's coercion model, and that then calls _cmp_ (single underscore). So, if you ever want to implement comparison of elements of a parent structure, I recall that you must *not* implement __cmp__ but _cmp_. In this case, the common parent is the matrix space of *dense* 3x3 matrices over GF(43). So, relevant is the _cmp_ method of the matrix R (since while comparing L and R, L is sent to R's parent). "R._cmp_?" shows that the comparison is forwarded to yet another method (WHY??), namely _cmp_c_impl. And I am afraid I can not find _cmp_c_impl. So, it is indeed confusing. Cheers, Simon -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
