Cadabra Computer algebra system for field theory problems
Cleanup

## Module Description

Functionality to clean up expressions so that they satisfy the requirements of a consistent expression tree.

## Functions

void cadabra::cleanup_dispatch (const Kernel &kernel, Ex &tr, Ex::iterator &it)

void cadabra::cleanup_dispatch_deep (const Kernel &k, Ex &tr, dispatcher_t dispatch)

## ◆ cleanup_dispatch()

 void cadabra::cleanup_dispatch ( const Kernel & k, Ex & , Ex::iterator & it )

Central cleanup dispatch routine, which calls the other cleanup functions defined later.

These cleanup routines do NOT use normal cadabra algorithms; they are completely independent of them to prevent circular dependence or infinite recursion.

These algorithms clean up the tree at the current node and the first layer of child nodes, but do NOT descend deeper down the tree, UNLESS that would leave the tree in an inconsistent state. An example is acting at the top node of \prod{4}{\sum{a}{b}}, which would push the 4 to the multiplier of the sum, but that is not allowed, so it needs to go further down. Sibling nodes of 'it' remain untouched as well.

## ◆ cleanup_dispatch_deep()

 void cadabra::cleanup_dispatch_deep ( const Kernel & k, Ex & , dispatcher_t disp = &cleanup_dispatch )

More general cleanup of an entire tree. Walks depth-first along the entire tree and call cleanup_dispatch at every node.