dgholstein
06-23-2008, 06:31 PM
I've used NR3 interpolation classes to construct the following error function:
// function calculates error function as a function of sigma and dielectric
// result is square of differences
Doub error_sq_func(VecDoub x)
{
int i, j;
double sigma, dielectric, result, sum = 0.0;
sigma = x[0]; dielectric = x[1];
for (i=0; i<func_parameters.n_splines; i++) {
if (eval_spline((unsigned long *) func_parameters.spline+i, sigma, dielectric, &result, func_parameters.error) < 0)
return NaN;
sum += sqr(func_parameters.vals[i] - result);
}
Of course, most of the code isn't shown here, but it has been tested and works well.
I just can't figure out how to call the Powell minimizer, all my attempts at building a constructor come up empty -- I've been trying to construct the second instance mentioned on page 513 of the book (with simple C++ function instead of functor). :confused:
Does anyone have an example of Powell minimization? Is there another place for NR3 examples?
...Dan
// function calculates error function as a function of sigma and dielectric
// result is square of differences
Doub error_sq_func(VecDoub x)
{
int i, j;
double sigma, dielectric, result, sum = 0.0;
sigma = x[0]; dielectric = x[1];
for (i=0; i<func_parameters.n_splines; i++) {
if (eval_spline((unsigned long *) func_parameters.spline+i, sigma, dielectric, &result, func_parameters.error) < 0)
return NaN;
sum += sqr(func_parameters.vals[i] - result);
}
Of course, most of the code isn't shown here, but it has been tested and works well.
I just can't figure out how to call the Powell minimizer, all my attempts at building a constructor come up empty -- I've been trying to construct the second instance mentioned on page 513 of the book (with simple C++ function instead of functor). :confused:
Does anyone have an example of Powell minimization? Is there another place for NR3 examples?
...Dan