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

6.2.3 Function options

GiNaC functions understand several more options which are always specified as .option(params). None of them are required, but you need to specify at least one option to REGISTER_FUNCTION(). There is a do-nothing option called dummy() which you can use to define functions without any special options.

 
eval_func(<C++ function>)
evalf_func(<C++ function>)
derivative_func(<C++ function>)
series_func(<C++ function>)
conjugate_func(<C++ function>)

These specify the C++ functions that implement symbolic evaluation, numeric evaluation, partial derivatives, and series expansion, respectively. They correspond to the GiNaC methods eval(), evalf(), diff() and series().

The eval_func() function needs to use .hold() if no further automatic evaluation is desired or possible.

If no series_func() is given, GiNaC defaults to simple Taylor expansion, which is correct if there are no poles involved. If the function has poles in the complex plane, the series_func() needs to check whether the expansion point is on a pole and fall back to Taylor expansion if it isn't. Otherwise, the pole usually needs to be regularized by some suitable transformation.

 
latex_name(const string & n)

specifies the LaTeX code that represents the name of the function in LaTeX output. The default is to put the function name in an \mbox{}.

 
do_not_evalf_params()

This tells evalf() to not recursively evaluate the parameters of the function before calling the evalf_func().

 
set_return_type(unsigned return_type, unsigned return_type_tinfo)

This allows you to explicitly specify the commutation properties of the function (See section Non-commutative objects, for an explanation of (non)commutativity in GiNaC). For example, you can use set_return_type(return_types::noncommutative, TINFO_matrix) to make GiNaC treat your function like a matrix. By default, functions inherit the commutation properties of their first argument.

 
set_symmetry(const symmetry & s)

specifies the symmetry properties of the function with respect to its arguments. See section Indexed objects, for an explanation of symmetry specifications. GiNaC will automatically rearrange the arguments of symmetric functions into a canonical order.

Sometimes you may want to have finer control over how functions are displayed in the output. For example, the abs() function prints itself as ‘abs(x)’ in the default output format, but as ‘|x|’ in LaTeX mode, and fabs(x) in C source output. This is achieved with the

 
print_func<C>(<C++ function>)

option which is explained in the next section.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.