Function of several variables
Suppose we have a function of several variables:
YMul = a*Sin(b+2*x1)+Sqr(x2),
where x1,x2 are two variables and a,b are two additional constants. Here is how we would define function yMul: TRealFunction;
function y(
const Pars:
TVec;
const Consts:
TVec;
const OConsts:
Array of TObject):
double;
begin
y := Consts[0]*Sin(Consts[1]+2.0*Pars[0])+ Sqr(Pars[1]);
end;
...
// calculate YMul=YMul(1,1) and set a,b constants to 2 and 3 respectively.
var constVec, parsVec:
Vector;
begin
constVec := [3,2];
parsVec := [1,1];
result := yMul(parsVec,constVec,[]);