[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] gsl_linear_interp example
From: |
Daniel J Farrell |
Subject: |
Re: [Help-gsl] gsl_linear_interp example |
Date: |
Thu, 7 Jun 2007 08:55:01 +0100 |
Sorry made silly mistake:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gsl/gsl_interp.h>
int main (void)
{
//sample data
double x[4] = { 1970, 1980, 1990, 2000 };
double y[4] = { 12, 11, 14, 13 };
//inialise and allocate the gsl objects
gsl_interp *interpolation = gsl_interp_alloc(gsl_interp_linear,
4);
gsl_interp_init(interpolation, x, y, 4);
gsl_interp_accel * accelerator = gsl_interp_accel_alloc();
//get interpolation for x = 1981
double value = gsl_interp_eval(interpolation, x, y, 1981,
accelerator);
printf("\n%g",value);
//output:
//11.3
return 0;
}
On 6 Jun 2007, at 23:39, Daniel J Farrell wrote:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gsl/gsl_interp.h>
int main (void)
{
//sample data
double x[4] = { 1970, 1980, 1990, 2000 };
double y[4] = { 12, 11, 14, 13 };
//inialise and allocate the gsl objects
gsl_interp *interpolation = gsl_interp_alloc
(gsl_interp_linear,n);
gsl_interp_init(interpolation, x, y, n);
gsl_interp_accel * accelerator = gsl_interp_accel_alloc();
//get interpolation for x = 1981
double value = gsl_interp_eval(interpolation, x, y, 1981,
accelerator);
printf("\n%g",value);
//output:
//11.3
return 0;
}