Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / fft / test_trap_source.c
1 /* fft/test_trap.c
2  * 
3  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
4  * 
5  * This program 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 3 of the License, or (at
8  * your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 void FUNCTION(test,trap) (void);
21
22 void
23 FUNCTION(test,trap) (void)
24 {
25   int status ;
26
27   BASE real_x ;
28   BASE complex_x ;
29
30   BASE * real_data = &real_x ;
31   BASE * complex_data = &complex_x  ; 
32
33   TYPE(gsl_fft_complex_wavetable) * cw;
34   TYPE(gsl_fft_real_wavetable) * rw;
35   TYPE(gsl_fft_halfcomplex_wavetable) * hcw;
36
37   TYPE(gsl_fft_complex_workspace) * cwork;
38   TYPE(gsl_fft_real_workspace) * rwork;
39
40   /* n = 0 in alloc */
41
42   cw = FUNCTION(gsl_fft_complex_wavetable,alloc) (0);
43   gsl_test (cw != 0, "trap for n = 0 in " NAME(gsl_fft_complex_wavetable) "_alloc");
44
45   rw = FUNCTION(gsl_fft_real_wavetable,alloc) (0);
46   gsl_test (rw != 0, "trap for n = 0 in " NAME(gsl_fft_real_wavetable) "_alloc" );
47
48   hcw = FUNCTION(gsl_fft_halfcomplex_wavetable,alloc) (0);
49   gsl_test (hcw != 0, "trap for n = 0 in " NAME(gsl_fft_halfcomplex_wavetable) "_alloc");
50
51   cwork = FUNCTION(gsl_fft_complex_workspace,alloc) (0);
52   gsl_test (cw != 0, "trap for n = 0 in " NAME(gsl_fft_complex_workspace) "_alloc");
53
54   rwork = FUNCTION(gsl_fft_real_workspace,alloc) (0);
55   gsl_test (rw != 0, "trap for n = 0 in " NAME(gsl_fft_real_workspace) "_alloc" );
56
57   cw = FUNCTION(gsl_fft_complex_wavetable,alloc) (10);
58   hcw = FUNCTION(gsl_fft_halfcomplex_wavetable,alloc) (10);
59   rw = FUNCTION(gsl_fft_real_wavetable,alloc) (10);
60
61   cwork = FUNCTION(gsl_fft_complex_workspace,alloc) (10);
62   rwork = FUNCTION(gsl_fft_real_workspace,alloc) (10);
63
64   /* n = 0 in fft forward */
65
66   status = FUNCTION(gsl_fft_complex,forward) (complex_data, 1, 0, cw, cwork);
67   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_complex) "_forward");
68
69   status = FUNCTION(gsl_fft_real,transform) (real_data, 1, 0, rw, rwork);
70   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_real) "_transform");
71
72   status = FUNCTION(gsl_fft_halfcomplex,transform) (real_data, 1, 0, hcw, rwork);
73   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_halfcomplex) "_transform");
74
75   status = FUNCTION(gsl_fft_complex,radix2_forward) (complex_data, 1, 0);
76   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_complex) "_radix2_forward");
77
78   /* n = 0 in fft backward */
79
80   status = FUNCTION(gsl_fft_complex,backward) (complex_data, 1, 0, cw, cwork);
81   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_complex) "_backward");
82
83   status = FUNCTION(gsl_fft_complex,radix2_backward) (complex_data, 1, 0);
84   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_complex) "_radix2_backward");
85
86   /* n = 0 in fft inverse */
87
88   status = FUNCTION(gsl_fft_complex,inverse) (complex_data, 1, 0, cw, cwork);
89   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_complex) "_inverse");
90
91   status = FUNCTION(gsl_fft_complex,radix2_inverse) (complex_data, 1, 0);
92   gsl_test (!status, "trap for n = 0 in " NAME(gsl_fft_complex) "_radix2_inverse");
93
94   /* n != 2^k in power of 2 routines */
95
96   status = FUNCTION(gsl_fft_complex,radix2_forward) (complex_data, 1, 17);
97   gsl_test (!status, "trap for n != 2^k in " NAME(gsl_fft_complex) "_radix2_forward");
98
99   status = FUNCTION(gsl_fft_complex,radix2_backward) (complex_data, 1, 17);
100   gsl_test (!status, "trap for n != 2^k in " NAME(gsl_fft_complex) "_radix2_backward");
101
102   status = FUNCTION(gsl_fft_complex,radix2_inverse) (complex_data, 1, 17);
103   gsl_test (!status, "trap for n != 2^k in " NAME(gsl_fft_complex) "_radix2_inverse");
104
105   /* n != wavetable.n in mixed radix routines */
106
107   cw->n = 3;
108   status = FUNCTION(gsl_fft_complex,forward) (complex_data, 1, 4, cw, cwork);
109   gsl_test (!status, "trap for n != nw in " NAME(gsl_fft_complex) "_forward");
110
111   cw->n = 3;
112   status = FUNCTION(gsl_fft_complex,backward) (complex_data, 1, 4, cw, cwork);
113   gsl_test (!status, "trap for n != nw in " NAME(gsl_fft_complex) "_backward");
114
115   cw->n = 3;
116   status = FUNCTION(gsl_fft_complex,inverse) (complex_data, 1, 4, cw, cwork);
117   gsl_test (!status, "trap for n != nw in " NAME(gsl_fft_complex) "_inverse");
118
119   rw->n = 3;
120   status = FUNCTION(gsl_fft_real,transform) (real_data, 1, 4, rw, rwork);
121   gsl_test (!status, "trap for n != nw in " NAME(gsl_fft_real) "_transform");
122
123   hcw->n = 3;
124   status = FUNCTION(gsl_fft_halfcomplex,transform) (real_data, 1, 4, hcw, rwork);
125   gsl_test (!status, "trap for n != nw in " NAME(gsl_fft_halfcomplex) "_transform");
126
127   FUNCTION (gsl_fft_halfcomplex_wavetable,free) (hcw) ;
128   FUNCTION (gsl_fft_real_wavetable,free) (rw) ;
129   FUNCTION (gsl_fft_complex_wavetable,free) (cw) ;
130
131   FUNCTION (gsl_fft_real_workspace,free) (rwork) ;
132   FUNCTION (gsl_fft_complex_workspace,free) (cwork) ;
133
134 }
135
136
137
138