This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question about root finding example


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]