Hi, I have been extending GiNaC in various ways, but something I haven't yet fathomed is the canonical ordering that automatically happens. 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. What determines and triggers the canonical ordering? Perhaps this could also be explained somewhere in the reference. sincerely, Garnet
Hi! 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() function.
What determines and triggers the canonical ordering?
The add and mul classes canonicalize their children at construction time. Bye, Christian -- / Coding on PowerPC and proud of it \/ http://www.uni-mainz.de/~bauec002/
participants (2)
-
Christian Bauer
-
Garnet Kin-Lic Chan