Re: [Help-gsl] Keeping fixed memory allocation for an interpolating object

2013-10-14 Thread Sam Mason
On 14 October 2013 10:52, Ruben Farinelli farine...@fe.infn.it wrote:
 However allocating at each call in the function the dimension of the object
 and then freeing it via the commands

 spline=gsl_spline_alloc(gsl_interp_cspline, BIN);
 gsl_spline_init(spline, array_x, array_y, BIN);

 /* commands */

 gsl_spline_free(spline);

 is very time consuming.

If you could post the whole of your loop it would help, i.e. what are
you doing in commands?  Why don't you do something like the manual
example?

  
http://www.gnu.org/software/gsl/manual/html_node/Interpolation-Example-programs.html

Hope that helps!

  Sam



Re: [Help-gsl] Keeping fixed memory allocation for an interpolating object

2013-10-14 Thread Patrick Alken
You can allocate the 'spline' object once and pass it to the function,
as long as your BIN parameter stays the same for each function call.

On 10/14/2013 03:52 AM, Ruben Farinelli wrote:
 Dear GSL,
 I have the following question.
 
 I need to pass thousands of times two arrays to a custom function in order to 
 perform a spline interpolation.
 However allocating at each call in the function the dimension of the object 
 and then freeing it via the commands
 
 spline=gsl_spline_alloc(gsl_interp_cspline, BIN);  
 gsl_spline_init(spline, array_x, array_y, BIN); 
 
 \*commands
 
 /*
 
 gsl_spline_free(spline);
 
 
 is very time consuming.
 What I would like to do is allocating the object just once, i.e. when the 
 function is called for the first time, and then proceed on up to the end
 of the loop.
 How can I do that ?
 
 Thank you in advance
 Best regards
 
 Ruben Farinelli