[GU] Simplify point-wise Field operations
Currently, point-wise operations on Nifty objects are not really implemented in a beautiful way: they are injected via some nasty Python tricks into Field
, MultiField
, Operator
and the sugar
module, and a slightly more complicated variant is added to Linearization
.
My plan is to have a single method in Field
, MultiField
, Linearization
and Operator
, which is called ptw
(or pointwise
), which takes a string describing the requested pointwise operation (like "sin", "exp", "one_over" etc.). Implementation of the actual operations would be fairly trivial via a dictionary mapping these names to their numpy
equivalents, and also describing their derivatives via numpy
or custom functions where necessary.
If we like, we can leave the global pointwise functions injected into sugar.py
unchanged for aesthetic reasons :)
Opinions?