[GiNaC-list] simplify_indexed and inheritance

Christian Bauer Christian.Bauer at uni-mainz.de
Thu Mar 17 15:42:50 CET 2005


Hi!

On Tue, Mar 15, 2005 at 06:54:01PM -0300, mdias at ift.unesp.br wrote:
> I have a simple question. I would like to construct a derived class of
> indexed type, folowing the final part of tutorial. How can I inherit
> simplify_indexed()?

You can't, as there is no member function simplify_indexed().

What you can override is eval_indexed() (for automatic evaluation) and
contract_with()/add_indexed()/scalar_mul_indexed() (for manual evaluation,
AKA simplify_indexed()). However, these are not methods of the 'indexed'
class but of the base objects that are being indexed.

You probably don't need to subclass 'indexed' at all. The library is
designed in a way that allows putting nearly all relevant properties of
indexed expressions into their base objects. If you still want to do it:
take a look at GiNaC's 'color' class (color.h/color.cpp) which is pretty
minimal, except for its eval_ncmul() (the main purpose of the color class
is to implement the proper noncommutative behavior of indexed color
objects).

Bye,
Christian

-- 
  / Physics is an algorithm
\/ http://www.uni-mainz.de/~bauec002/




More information about the GiNaC-list mailing list