I have a function f() that is not analytic and therefore I need to find a
numerical gradient. However to initialize a gsl_multimin_function_fdf, I
still need a function my_df that simply returns the value of the gradient at
the specified point.
For testing, lets try it with a function that we COULD have taken a normal
gradient of (this example ships with the package)
double my_f (const gsl_vector *v, void *params)
{
double x, y;
double *dp = (double *)params;
x = gsl_vector_get(v, 0);
y = gsl_vector_get(v, 1);
return 10.0 * (x - dp[0]) * (x - dp[0]) +
20.0 * (y - dp[1]) * (y - dp[1]) + 30.0;
}
and its gradient:
void my_df (const gsl_vector *v, void *params, gsl_vector *df)
{
double x, y;
double *dp = (double *)params;
x = gsl_vector_get(v, 0);
y = gsl_vector_get(v, 1);
gsl_vector_set(df, 0, 20.0 * (x - dp[0]));
gsl_vector_set(df, 1, 40.0 * (y - dp[1]));
}
but instead i would like: (and I imagine I should keep the same function
form (ie. same parameters))
void my_df (const gsl_vector *v, void *params, gsl_vector *df)
{
NUMERICAL GRADIENT OF f at v;
}
Is there a function I can call that will do that?
--
Thanks,
David
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl