Added MACS source
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / doc / examples / cheb.c
1 #include <stdio.h>
2 #include <gsl/gsl_math.h>
3 #include <gsl/gsl_chebyshev.h>
4
5 double
6 f (double x, void *p)
7 {
8   if (x < 0.5)
9     return 0.25;
10   else
11     return 0.75;
12 }
13
14 int
15 main (void)
16 {
17   int i, n = 10000; 
18
19   gsl_cheb_series *cs = gsl_cheb_alloc (40);
20
21   gsl_function F;
22
23   F.function = f;
24   F.params = 0;
25
26   gsl_cheb_init (cs, &F, 0.0, 1.0);
27
28   for (i = 0; i < n; i++)
29     {
30       double x = i / (double)n;
31       double r10 = gsl_cheb_eval_n (cs, 10, x);
32       double r40 = gsl_cheb_eval (cs, x);
33       printf ("%g %g %g %g\n", 
34               x, GSL_FN_EVAL (&F, x), r10, r40);
35     }
36
37   gsl_cheb_free (cs);
38
39   return 0;
40 }