help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] gsl_function with pointer


From: James Bergstra
Subject: Re: [Help-gsl] gsl_function with pointer
Date: Sat, 7 Oct 2006 16:58:48 -0400
User-agent: Mutt/1.4.2.1i

On Sat, Oct 07, 2006 at 08:30:50PM +0200, Ivan Liu wrote:
> Hi,
> 
> I hope to use to declare a gsl_function by pointer, and
> use the integration rountine gsl_integration_qag in the
> following way:
> 
> 
> gsl_function * Integrand=0;
> Integrand->function = &f;
> Integrand->params = &list;
> 
> gsl_integration_qag (Integrand, x_start, x_end, epsabs, epsrel, limit, 1,
> w, &resIntegral, &abserr);

There may be other problems, but for starters, you should allocate some memory
for your Integrand to point to.

    gsl_function * Integrand= malloc(sizeof(gsl_function));
    Integrand->function = &f;
    Integrand->params = &list;


    ...

    free(Integrand)


Also, in the future, you might consider looking into the basics of the GNU
debugger.  If you compile your code with the -g option (and no optimization
flags) then

$  gdb <your program>
...
> run  argv[1] argv[2] ...

Will run your program and show you what line triggered the segfault, as well as
what the stack looked like at the point of the crash, variable values, etc.


Best of luck,

James
-- 
http://www-etud.iro.umontreal.ca/~bergstrj





reply via email to

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