Example:
#include<function2d.h>
...
class my_function: public Function2d<double,double>
{
public:
// data
double mx,my,c;
// input and output
void Read(istream& stream) { stream >> mx >> my >> c; }
void Write(ostream& stream) const { stream << mx << ' ' << my << ' ' << c; }
// evaluation
double evaluate(const double& x, const double& y)
{ return mx * x + my * y + c; }
};
The method `()' is defined to evaluate the function, e.g.
my_function f1; cin >> f1; // read parameters double x,y; cin >> x >> y; // read argument double f = f1(x,y); cout << f << endl; // evaluate function
Function2d<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.
Realfunction2d_1dproductRealfunction1d.
#include<function2d.h> ... Realfunction2d_1dproduct p; cin >> p; double x,y; cin >> x >> y; double f = p(x,y); cout << f << endl;
Realfunction2d_1dinterp_1Realfunction1d)
to use at that value.
The result is interpolated between the nearest pair of functions.
Realfunction2d_1dinterp_2Realfunction1d)
to use at that value.
The result is interpolated between the nearest pair of functions.
Realfunction2d_table
nx ny (dimensions of table)
For each x:
xi (x-ordinates)
For each y:
yj (y-ordinates)
For each x:
For each y:
fi,j (function values)
#include<function2d.h> ... Realfunction2d_table t; cin >> t; double x,y; cin >> x >> y; double f = t(x,y); cout << f << endl; // evaluate function
Realfunction2d_table_bipolyxorder yorder (order of polynomials used to interpolate in x and y) xfirst (1/0 for interpolation in x first/second)
Realfunction2d_sumnumber_of_functions For each: fiEach
fi is a Realfunction2d.
Realfunction2d_productnumber_of_functions For each: fiEach
fi is a Realfunction2d.
Realfunction2d_offsetx0 y0 f
f is a Realfunction2d.
Realfunction2d_mapxmap ymap fmap f
xmap, ymap and fmap are
Realfunction1ds.
f is a Realfunction2d.