You are here: Symbol Reference > MtxVec Namespace > Types > MtxVec.TRealFunction Type
MtxVec VCL
ContentsIndex
Example 1

Function of one variable

Suppose we have a function of one variable: 

y = a*Sin(b+2*x), 

where x is a variable and a,b are two additional constants. Here is how we would define function y: TRealFunction

 

function y(const Pars: TVec; const Consts: TVec; Const Objects: Array of TObject): double; begin y := Consts[0]*Sin(Consts[1]+2.0*Pars[0]); end; ... // calculate y=y(2.5) and set a,b, constants to 3 and 2 respectively var constVec, parsVec: Vector; constVec := [3,2]; parsVec := [2.5]; y(parsVec,constsVec,[]);
double __fastcall y(const TVec * Parameters, const TVec * Constants, System::TObject* const * ObjConst, const int ObjConst_Size) { return Consts[0]*Sin(Consts[1]+2.0*Parameters[0]); } ... // calculate y=y(2.5) and set a,b, constants to 3 and 2 respectively sVector parsVec, constVec; parsVec.SetIt(1, false, OPENARRAY(double,(2.5))); constVec.SetIt(2, false, OPENARRAY(double,(3,2))); y(parsVec, constVec, NULL,-1);
Copyright (c) 1999-2025 by Dew Research. All rights reserved.