Origin Ver. 8.5.0 SR1
Operating System: Win7
Hi everybody,
I have a problem (very basic I assume) using originc and specifically with the function e04abc. It wants me to input a "Function" to minimize - but what kind of object is that? It seems not to be happy when I just type in the name of a funtion that i defined as "double pwrerrfit(double x)" (see below). I'm not really sure whether a function in the context of minimization is something different from a method (as defined eg by my "double pwrerrfit(double x) {...}")
Many thanks in advance,
Max
// Fit a powerlaw function to data and return fit results
void fitpwrwinoct(vector tfit, vector sigfit, double &x0, double &l1, double &l2)
{
// tfit, sigfit are global variables
printf("Fit started.\n");
double a, b;
double e1, e2;
double x, f;
int maxiter;
Nag_Comm comm;
static NagError fail;
e1 = 0.0;
e2 = 0.0;
a = 0.0;
b = 5.0;
maxiter = 50;
e04abc(pwrerrfit, e1, e2, &a, &b, maxiter, &x, &f, &comm, &fail);
// now obtain coefficients of the power law fit
vector tx;
tx = tfit^fitx;
vector vc;
fitlinear(tx, sigfit, vc);
l1=vc[1];
l2=vc[0];
x0= fitx;
printf("Fit done.\n");
}
// fit a powerlaw function with exponent x to t,r data
double pwrerrfit(double x)
{
// tfit, sigfit are global variables
vector tx;
tx = tfit^x;
vector vc;
fitlinear(tx, sigfit, vc);
vector vc0, vc1;
int nSize = tx.GetSize();
createConstantVector(vc[0], nSize, vc0);
createConstantVector(vc[1], nSize, vc1);
vector diff, squares;
squares = (vc0+tx*vc1-sigfit)^2;
double sumSquares;
squares.Sum(sumSquares);
return sumSquares;
}