This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: question about root finding example
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: Faheem Mitha <faheem at email dot unc dot edu>
- Cc: gsl-discuss at sources dot redhat dot com
- Date: Wed, 11 Jun 2003 18:59:53 +0100
- Subject: Re: question about root finding example
- References: <Pine.LNX.4.44.0306060030260.15726-100000@Chrestomanci>
Faheem Mitha writes:
> I have a question about the example in the GSl documentation which
> appears at the bottom of this message. In the main do loop, status
> is assigned to twice. Namely,
> status = gsl_root_fsolver_iterate (s);
> and then
> status = gsl_root_test_interval (x_lo, x_hi,
> I'm unclear on what the first assignment does. Surely, regardless
> of the value, it is overwritten by the second line?
The value is discarded, it's just to show that there is a return value.
> Also, I am not really clear on what is going on with
> gsl_root_fsolver_iterate. However, I took the lazy way out and ran
> through it with a debugger. The first line returns 0 on every loop,
0 = success
> the second returns -2 (GSL_CONTINUE) for the first few loops, which
> is correct.
>
> I realise that gsl_root_fsolver_iterate needs to be called, since
> it is preforming the actual algorithm (if I'm following this
> correctly) but why does it need to write to status, and why is
> returning 0 for status anyway, when -2 would be correct?
the iteration might fail (e.g. singularity or something like that)
in which case iterate() would return a non-zero error code.
I should probably add a line like if(status) break; after the call to
iterate().
--
Brian
Network Theory Ltd
15 Royal Park
Bristol BS8 3AL
United Kingdom
Tel: +44 (0)117 3179309
Fax: +44 (0)117 9048108
Web: http://www.network-theory.co.uk/