canonical ordering

Christian Bauer cbauer at
Mon Mar 11 21:18:25 CET 2002


On Sun, Mar 10, 2002 at 12:24:26AM -0800, Garnet Kin-Lic Chan wrote:
> For example, I derived a class from indexed, whose compare_same_type
> simply calls the inherited::compare_same_type, yet the ordering of
> products in my class was different from that of the usual indexed objects.

The ordering is determined by basic::compare() which uses hash keys to speed
up the process. The default hash function basic::calchash() uses the
object's tinfo key for the computation. compare_same_type() only gets called
when the hash and tinfo keys are identical. That's why you're seeing
different orderings on (different) classes with the same compare_same_type()

> What determines and triggers the canonical ordering?

The add and mul classes canonicalize their children at construction time.


  / Coding on PowerPC and proud of it

More information about the GiNaC-list mailing list