[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] gsl_linear_interp example
From: |
Daniel J Farrell |
Subject: |
[Help-gsl] gsl_linear_interp example |
Date: |
Wed, 6 Jun 2007 14:42:22 +0100 |
Hello,
I am trying to find example code on how to do a linear interpolation.
So far I can allocate and initalise the gsl_interp object, but I get
a bit stuck when I need to query it for interpolation values; do I
have to use an accelerator?
Any advice?
Regards,
Dan.
___
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_interp.h>
int main (void)
{
unsigned n = 4;
double x[n] = { 1970, 1980, 1990, 2000 };
double y[n] = { 12, 11, 14, 13 };
//interpolation
gsl_interp *interp = gsl_interp_alloc(gsl_interp_linear,n);
gsl_interp_init(interp, x, y, n);
//get interpolation for x = 1981 here...
gsl_interp_free(interp);
return 0;
}
- [Help-gsl] gsl_linear_interp example,
Daniel J Farrell <=