Multi-dimensional functions

Header file functionnd.h

Real function of a real vector: class `Realfunctionnd'

A virtual base class for polymorphic functions. Inherits from Function<Vector,double>. A generic write-with-switch is provided for writing pointered polymorphic subclasses. The corresponding read-with-switch is provided for groups of functions in the library.

To use, define a pointer to an instance of the appropriate class. Data in an input stream must first specify the class identifier (the name, with lowercase first character) then the data. When writing to an output stream, the identifier is written followed by the data. Example:

#include<functionnd.h>
int main()
{
Realfunctionnd *f; cin >> f;
Vector r; cin >> r;
cout << "f(r) = " << (*f)(r) << endl;
}

Product of 1D functions

Data: a set of Realfunction1ds.

A single 1D function

Data: a Realfunction1d and the component index (base 0) which the function acts on.

A single 2D function

Data: a Realfunction2d and the two component indices (base 0) which the function acts on.

A single 3D function

Data: a Realfunction3d and the three component indices (base 0) which the function acts on.

Sum

Data: a set of Realfunctionnds.

Product

Data: a set of Realfunctionnds.

Offset

Data: a reference vector r0 and a Realfunctionnd f. Evaluating the function with an argument (vector) r produces f(r-r0).

Map

Data: an array of Realfunction1ds, rmap, one for each spatial dimension, another Realfunction1d, fmap, for the function return value, and a Realfunctionnd f. Evaluating the function with an argument (vector) r, a modified vector r' is calculated, where each of its components is found from the corresponding component of r using the corresponding function from rmap:
r'[i] = rmap[i](r[i]).

The function value returned is fmap(f(r')).

Among many other applications, this class is useful for re-scaling variables.