#include "MtxExpr.hpp"
#include "Math387.hpp"
#include "MtxVecTools.hpp"
// define the real function to be minimized
double __fastcall VecFun(
TVec*
const Parameters,
TVec*
const Constants, System::TObject*
const * ObjConst,
const int ObjConst_Size)
{
double* pars = Parameters->PValues1D(0);
TVec *tmpVec =
dynamic_cast<
TVec*>(ObjConst[0]);
return (pars[0] * tmpVec->Sum() - pars[1] * tmpVec->SumOfSquares());
}
void __fastcall Example(
TMtxOptimization* opt1);
{
// ...
opt1->
RealFunction = VecFun;
opt1->
VariableParameters->SetIt(
false,OPENARRAY(
double,(-1,0)));
sVector xVec;
TObject* o[1];
o[0] = xVec;
opt1->SetObjects(o,0);
}