Defines vector function of several variables.
Defines vector function of several variables.
Example 1
Define the vector function f(x,y) with three components: Uses MtxVec, Math387;
procedure VecFun(x,f: TVec; Const c: Array of TSample; Const o: Array of TObject);
begin
f[0] := x[0]*Sqrt(Sqr(x[0]+Sqr(x[1]));
f[1] := x[1]*Sqrt(Sqr(x[0]+Sqr(x[1]));
f[2] := x[0]*Sqr(x[1]-x[0]);
end;
#include "MtxVecCpp.h" //MtxVecCPP.cpp must be included in the project
#include "Math387.hpp"
void __fastcall VecFun(TVec* x, TVec* f, const double* c, conts int c_count,
System::TObject* const* o, const int o_count);
{
double* X = X.PValues1D(0);
(*f)[0] = X[0]*Sqrt(X[0]*X[0]+X[1]*X[1]);
(*f)[1] = X[1]*Sqrt(X[0]*X[0]+X[1]*X[1]);
(*f)[2] = X[0]*(X[1]-X[0])*(X[1]-X[0]);
}
private void VecFun(TVec x, TVec f, double[] c, object[] o)
{
f[0] = x[0]*Math.Sqrt(x[0]*x[0]+x[1]*x[1]);
f[1] = x[1]*Math.Sqrt(x[0]*x[0]+x[1]*x[1]);
f[2] = x[0]*(x[1]-x[0])*(x[1]-x[0]);
}