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

6.2 Symbolic functions

The easiest and most instructive way to start extending GiNaC is probably to create your own symbolic functions. These are implemented with the help of two preprocessor macros:

 
DECLARE_FUNCTION_<n>P(<name>)
REGISTER_FUNCTION(<name>, <options>)

The DECLARE_FUNCTION macro will usually appear in a header file. It declares a C++ function with the given ‘name’ that takes exactly ‘n’ parameters of type ex and returns a newly constructed GiNaC function object that represents your function.

The REGISTER_FUNCTION macro implements the function. It must be passed the same ‘name’ as the respective DECLARE_FUNCTION macro, and a set of options that associate the symbolic function with C++ functions you provide to implement the various methods such as evaluation, derivative, series expansion etc. They also describe additional attributes the function might have, such as symmetry and commutation properties, and a name for LaTeX output. Multiple options are separated by the member access operator ‘.’ and can be given in an arbitrary order.

(By the way: in case you are worrying about all the macros above we can assure you that functions are GiNaC's most macro-intense classes. We have done our best to avoid macros where we can.)


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