help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] error handling in gsl_root_fsolver_set()


From: Tommy Nordgren
Subject: Re: [Help-gsl] error handling in gsl_root_fsolver_set()
Date: Sat, 8 Dec 2007 13:37:20 +0100


On 8 dec 2007, at 13.29, Tommy Nordgren wrote:


On 7 dec 2007, at 00.19, jian Xu wrote:

Hello,

I'm using gsl 1-D root finding algorithm, and I need to use
gsl_root_fsolver_set( ... ) to initilize the solver.  The problem is
whenever the root is NOT located inside the bounds, this function call
will immediately breaks the program.  And I cannot catch its error
even if I put this function in a try block:

  try
  {
      gsl_root_fsolver_set (s, &f, x_lo, x_hi);
  }
  catch(...)
  {
      throw .......;   // Root is not bracked
  }

Is there anyway to catch the error generated by gsl_root_fsolver_set()
?  Thanks a lot.

Jian


What you need to do first, is rebuild the GSL library in a way that allows exceptions to be thrown past c code. This require a certain option to be passed to gcc, which is not passed by default. Then you need to set up an error handler function that throws an exception, instead of exiting
------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
address@hidden

        I've checked the gcc docs. The flag is -fexceptions

------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
address@hidden






reply via email to

[Prev in Thread] Current Thread [Next in Thread]