|
-
April 24th, 2009, 06:36 PM
#1
How to code a math formula and passing it to a function
hi!
I want to use a C++ function which receives a math function and executes minimization on it ( http://www.codecogs.com/d-ox/maths/o...ion/nelder.php) but I dont understand how to pass my formula as the first parameter.
There is even an example but I dont understand it...
Code:
double f(double *x) {
double r = sqrt(x[0] * x[0] + x[1] * x[1]);
return ABS(r) < 1E-12 ? 1 : sin(r) / r;
}
My formula is: http://personal.telefonica.terra.es/...dio1/text3.gif
This is what I've made:
Code:
for (i=1;i<=numberOfAnchors;i++)
{
errorsquare+= pow( abs( x[i] - xestim + y[i] - yestim ) - distance[i] ) , 2 );
}
errorsquare=errorsquare/numberOfAnchors;
Thanks.
Last edited by Shadowrun; April 24th, 2009 at 06:40 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|