3D functions

Header file function3d.h

Generic 3D function class `Function3d'

A template class, generated on the classes of the argument and the result. Functions of this class take two arguments of the argument type and return a single value of the result type. Subclasses must provide identification, data, input/output and evaluation. Inherits from `Classio'.

Example:

#include<function3d.h>
...
class my_function: public Function3d<double,double>
{
   public:

   // data
   double mx,my,mz,c;

   // input and output
   void Read(istream& stream) { stream >> mx >> my >> mz >> c; }
   void Write(ostream& stream) const
   { stream << mx << ' ' << my << ' ' << mz << ' ' << c; }

   // evaluation
   double evaluate(const double& x, const double& y, const double& z)
   { return mx * x + my * y + mz * z + c; }
};

The method `()' is defined to evaluate the function, e.g.

my_function f1; cin >> f1; // read parameters
double x,y,z; cin >> x >> y >> z; // read argument
double f = f1(x,y,z); cout << f << endl; // evaluate function

Real 3D function class `Realfunction3d'

Inherits from Function3d<double,double&ht;

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.

Product of three 1D functions: Realfunction3d_1dproduct

Data is a set of three Realfunction1ds.
#include<function3d.h>
...
Realfunction3d_1dproduct p; cin >> p;
double x,y,z; cin >> x >> y >> z;
double f = p(x,y,z); cout << f << endl;

Interpolated array of 2D functions: Realfunction3d_2dinterp

Data is an array of pairs of values of one argument and functions of the two arguments (Realfunction2d) to use at that value, followed by three integers describing the mapping between the arguments of the 3D function and the 2D function. The result is interpolated between the nearest pair of functions. The mapping is a set of indices whose position relates to the 3D argument, and whose value defines the position in the 2D argument. Position "0" refers to the ordinate controlling which pair of functions is used for the interpolation. Positons "1" and "2" refer to the first and second arguments of the 2D function.

Sum: Realfunction3d_sum

A set of 3D functions {fi}. The function returned is the sum of each fi. Data:
number_of_functions
For each:
   fi
Each fi is a Realfunction3d.

Displaced function: Realfunction3d_offset

A function f and an offset x0 y0 z0 to its argument, the displaced function being f(x-x0,y-y0,z-z0). Data:
x0 y0 z0 f
f is a Realfunction3d.

Mapped function: Realfunction3d_map

A 3D function f and 1D functions xmap, ymap, zmap and fmap such that the function returned is fmap{f[xmap(x),ymap(y),zmap(z)]}. This is a fairly general form, but is particularly useful for changing units or scalings. Data:
xmap ymap zmap fmap
f
xmap, ymap, zmap and fmap are Realfunction1ds. f is a Realfunction3d.