X-shooter Pipeline Reference Manual 3.8.15
test-xsh_bspline_interpol.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2012-12-16 19:31:50 $
23 * $Revision: 1.1 $
24 */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*-------------------------------------------------------------------------*/
36/*-------------------------------------------------------------------------*/
39/*--------------------------------------------------------------------------
40 Includes
41 --------------------------------------------------------------------------*/
42
43#include <tests.h>
44
45#include <xsh_error.h>
46#include <xsh_msg.h>
47#include <cpl.h>
48
49#include <stdlib.h>
50#include <stdio.h>
51#include <math.h>
52#include <gsl/gsl_errno.h>
53#include <gsl/gsl_spline.h>
54#include <getopt.h>
55/*--------------------------------------------------------------------------
56 Defines
57 --------------------------------------------------------------------------*/
58
59#define MODULE_ID "XSH_BSPLINE_INTERPOL"
60
61
70int
72{
73 int i;
74 double xi, yi, x[10], y[10];
75 int ret=0;
76
77 /* Initialize libraries */
79
80
81 printf ("#m=0,S=2\n");
82
83 for (i = 0; i < 10; i++)
84 {
85 x[i] = i + 0.5 * sin (i);
86 y[i] = i + cos (i * i);
87 printf ("%g %g\n", x[i], y[i]);
88 }
89
90 printf ("#m=1,S=0\n");
91
92 {
93 gsl_interp_accel *acc
94 = gsl_interp_accel_alloc ();
95 gsl_spline *spline
96 = gsl_spline_alloc (gsl_interp_cspline, 10);
97
98 gsl_spline_init (spline, x, y, 10);
99
100 for (xi = x[0]; xi < x[9]; xi += 0.01)
101 {
102 yi = gsl_spline_eval (spline, xi, acc);
103 printf ("%g %g\n", xi, yi);
104 }
105 gsl_spline_free (spline);
106 gsl_interp_accel_free (acc);
107 }
108
109
110 if (cpl_error_get_code() != CPL_ERROR_NONE) {
111 xsh_error_dump(CPL_MSG_ERROR);
112 ret= 1;
113 }
114 TEST_END();
115 return ret ;
116
117
118}
119
120
#define MODULE_ID
int main()
Unit test of xsh_bspline_interpol.
#define xsh_error_dump(level)
Definition: xsh_error.h:92
int * y
int * x
#define TEST_END()
Definition: tests.h:111
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105