This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Area constraint in 2-d roots?
- From: "Peter S. Christopher" <peterc at midway dot uchicago dot edu>
- To: gsl-discuss at sources dot redhat dot com
- Date: Thu, 18 Jul 2002 14:54:00 -0500 (CDT)
- Subject: Area constraint in 2-d roots?
Hi there,
I'm inquiring about the gsl_multiroot_fsolver_iterate function.
Specifically I'm interested in constraining the allowable solutions that
the algorithm searches to a small area.
I'm using the gsl_multiroot_fsolver_hybrids algorithm. I am passing a
function that looks something like this
int zeroBmu(const gsl_vector *x, void *params, gsl_vector * f){
...
...
m0 = gsl_vector_get(x,0);
mA = gsl_vector_get(x,1);
...
...
return GSL_SUCCESS;
}
My problem is that I need to bracket m0 and mA; specifically these
parameters must be > 0.0 and < 1.0. The solution I'm using is something
like
int zeroBmu(const gsl_vector *x, void *params, gsl_vector * f){
...
...
/*be sure that x0,x1 are both > 0.0*/
gsl_vector_set((gsl_vector *)x, 0, fabs(gsl_vector_get(x,0)));
gsl_vector_set((gsl_vector *)x, 1, fabs(gsl_vector_get(x,1)));
m0 = gsl_vector_get(x,0);
mA = gsl_vector_get(x,1);
if( m0 >= 1.0)
{
/*do something that forces m0 to be smaller then 1.0. */
gsl_vector_set((gsl_vector *)x,0,m0);
}
if(mA >= 1.0)
{
/*ext.*/
}
...
...
...
return GSL_SUCCESS;
}
MY 2 QUESTIONS:
1) Will this provide the appropriate constraint.
2) Is there a more "elegant" way to do this. Maybe one that is
built into the solvers. Maybe something that doesn't force me to break the
"const gsl_vector *" of x with a cast.
Thanks for any help,
Pete Christopher