manpagez: man pages & more
info ginac
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5.4 Optional member functions

We have implemented only a small set of member functions to make the class work in the GiNaC framework. There are two functions that are not strictly required but will make operations with objects of the class more efficient:

 
unsigned calchash() const;
bool is_equal_same_type(const basic & other) const;

The calchash() method returns an unsigned hash value for the object which will allow GiNaC to compare and canonicalize expressions much more efficiently. You should consult the implementation of some of the built-in GiNaC classes for examples of hash functions. The default implementation of calchash() calculates a hash value out of the tinfo_key of the class and all subexpressions that are accessible via op().

is_equal_same_type() works like compare_same_type() but only tests for equality without establishing an ordering relation, which is often faster. The default implementation of is_equal_same_type() just calls compare_same_type() and tests its result for zero.


© manpagez.com 2000-2024
Individual documents may contain additional copyright information.