help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] [doc] One line to add in a example


From: Thomas Gerbaud
Subject: [Help-gsl] [doc] One line to add in a example
Date: Wed, 11 Jan 2006 15:07:13 +0100
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

Hi !

Thanks for the GSL, i'm using it in my PhD work, it helps me a lot.
A little correction in the manual :

http://www.gnu.org/software/gsl/manual/gsl-ref_26.html#SEC398
( interpolation )

At the end, a example is given : i think an allocation is missing ...

/#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_spline.h>

int
main (void)
{
 int i;
 double xi, yi, x[10], y[10];

 printf ("#m=0,S=2\n");

 for (i = 0; i < 10; i++)
   {
     x[i] = i + 0.5 * sin (i);
     y[i] = i + cos (i * i);
     printf ("%g %g\n", x[i], y[i]);
   }

 printf ("#m=1,S=0\n");

 {


*// NEED TO ADD THIS LINE ? */*
gsl_interp_cspline = (const  gsl_interp_type * ) malloc ( gsl_interp_cspline 
);*/

gsl_interp_accel *acc = gsl_interp_accel_alloc (); gsl_spline *spline = gsl_spline_alloc (gsl_interp_cspline, 10);

   gsl_spline_init (spline, x, y, 10);

   for (xi = x[0]; xi < x[9]; xi += 0.01)
     {
       yi = gsl_spline_eval (spline, xi, acc);
       printf ("%g %g\n", xi, yi);
     }
   gsl_spline_free (spline);
   gsl_interp_accel_free (acc);
 }
 return 0;/
}


Hope it helps, i'm not sure.

thomas





reply via email to

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