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

6.5.5 Other member functions

For a real algebraic class, there are probably some more functions that you might want to provide:

 
bool info(unsigned inf) const;
ex evalf(int level = 0) const;
ex series(const relational & r, int order, unsigned options = 0) const;
ex derivative(const symbol & s) const;

If your class stores sub-expressions (see the scalar product example in the previous section) you will probably want to override

 
size_t nops() cont;
ex op(size_t i) const;
ex & let_op(size_t i);
ex subs(const lst & ls, const lst & lr, unsigned options = 0) const;
ex map(map_function & f) const;

let_op() is a variant of op() that allows write access. The default implementations of subs() and map() use it, so you have to implement either let_op(), or subs() and map().

You can, of course, also add your own new member functions. Remember that the RTTI may be used to get information about what kinds of objects you are dealing with (the position in the class hierarchy) and that you can always extract the bare object from an ex by stripping the ex off using the ex_to<mystring>(e) function when that should become a need.

That's it. May the source be with you!


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