Debian Codegraph @

external/gsl/gsl_fft__real_init.c

raw symbols SCIP
1 /* fft/real_init.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 TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_wavetable) *
21 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_fft_real_wavetable,alloc) (size_t n)
22 {
23 int status;
24 size_t i;
25 size_t n_factors;
26 size_t t, product, product_1, q;
27 double d_theta;
28
29 TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_wavetable) * wavetable;
30
31 if (n == 0)
32 {
33 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("length n must be positive integer", GSL_EDOM, 0);
34 }
35
36 wavetable = (TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_wavetable) *)
37 malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_wavetable)));
38
39 if (wavetable == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
40 {
41 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate struct", GSL_ENOMEM, 0);
42 }
43
44 if (n == 1)
45 {
46 wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig. = 0;
47 }
48 else
49 {
50 wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig. = (TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_complex) *)
51 malloccxx . . $ malloc(bfcfa4d6b7f7ef64). ((n / 2) * sizeof (TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_complex)));
52
53 if (wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
54 {
55 /* error in constructor, prevent memory leak */
56
57 freecxx . . $ free(5d22bdacc48458e8).(wavetable) ;
58
59 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate trigonometric lookup table",
60 GSL_ENOMEM, 0);
61 }
62 }
63
64 wavetable->ncxx . . $ $anonymous_type_c2628f7688aa0c69_0#n. = n;
65
66 status = fft_real_factorizecxx . . $ fft_real_factorize(59465bcb0bde3658). (n, &n_factors, wavetable->factorcxx . . $ $anonymous_type_c2628f7688aa0c69_0#factor.);
67
68 if (status)
69 {
70 /* error in constructor, prevent memory leak */
71
72 freecxx . . $ free(5d22bdacc48458e8).(wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig.);
73 freecxx . . $ free(5d22bdacc48458e8).(wavetable) ;
74
75 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("factorization failed", GSL_EFACTOR, 0);
76 }
77
78 wavetable->nfcxx . . $ $anonymous_type_c2628f7688aa0c69_0#nf. = n_factors;
79
80 d_theta = 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / ((double) n);
81
82 t = 0;
83 product = 1;
84 for (i = 0; i < wavetable->nfcxx . . $ $anonymous_type_c2628f7688aa0c69_0#nf.; i++)
85 {
86 size_t j;
87 const size_t factor = wavetable->factorcxx . . $ $anonymous_type_c2628f7688aa0c69_0#factor.[i];
88 wavetable->twiddlecxx . . $ $anonymous_type_c2628f7688aa0c69_0#twiddle.[i] = wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig. + t;
89 product_1 = product; /* product_1 = p_(i-1) */
90 product *= factor;
91 q = n / product;
92
93 for (j = 1; j < factor; j++)
94 {
95 size_t k;
96 size_t m = 0;
97 for (k = 1; k < (product_1 + 1) / 2; k++)
98 {
99 double theta;
100 m = m + j * q;
101 m = m % n;
102 theta = d_theta * m; /* d_theta*j*k*q */
103 GSL_REALcxx . . $ `external/gsl/gsl_complex.h:88:9`!(wavetable->trig[t]) = cos (theta);
104 GSL_IMAGcxx . . $ `external/gsl/gsl_complex.h:89:9`!(wavetable->trig[t]) = sin (theta);
105
106 t++;
107 }
108 }
109 }
110
111 if (t > (n / 2))
112 {
113 /* error in constructor, prevent memory leak */
114
115 freecxx . . $ free(5d22bdacc48458e8).(wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig.);
116 freecxx . . $ free(5d22bdacc48458e8).(wavetable) ;
117
118 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("overflowed trigonometric lookup table",
119 GSL_ESANITY, 0);
120 }
121
122 return wavetable;
123 }
124
125 TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_workspace) *
126 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_fft_real_workspace,alloc) (size_t n)
127 {
128 TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_workspace) * workspace;
129
130 if (n == 0)
131 {
132 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("length n must be positive integer", GSL_EDOM, 0);
133 }
134
135 workspace = (TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_workspace) *)
136 malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_workspace)));
137
138 if (workspace == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
139 {
140 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate struct", GSL_ENOMEM, 0);
141 }
142
143 workspace->ncxx . . $ $anonymous_type_c2628f7688aa0c69_1#n. = n;
144
145 workspace->scratchcxx . . $ $anonymous_type_c2628f7688aa0c69_1#scratch. = (BASEcxx . . $ `./templates_on.h:65:9`! *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (n * sizeof (BASEcxx . . $ `./templates_on.h:65:9`!));
146
147 if (workspace->scratchcxx . . $ $anonymous_type_c2628f7688aa0c69_1#scratch. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
148 {
149 /* error in constructor, prevent memory leak */
150
151 freecxx . . $ free(5d22bdacc48458e8).(workspace) ;
152
153 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate scratch space", GSL_ENOMEM, 0);
154 }
155
156 return workspace;
157 }
158
159
160
161 void
162 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_fft_real_wavetable,free) (TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_wavetable) * wavetable)
163 {
164
165 /* release trigonometric lookup tables */
166
167 freecxx . . $ free(5d22bdacc48458e8). (wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig.);
168 wavetable->trigcxx . . $ $anonymous_type_c2628f7688aa0c69_0#trig. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
169
170 freecxx . . $ free(5d22bdacc48458e8). (wavetable) ;
171 }
172
173 void
174 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_fft_real_workspace,free) (TYPEcxx . . $ `./templates_on.h:228:9`!(gsl_fft_real_workspace) * workspace)
175 {
176
177 /* release scratch space */
178
179 freecxx . . $ free(5d22bdacc48458e8). (workspace->scratchcxx . . $ $anonymous_type_c2628f7688aa0c69_1#scratch.);
180 workspace->scratchcxx . . $ $anonymous_type_c2628f7688aa0c69_1#scratch. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
181
182 freecxx . . $ free(5d22bdacc48458e8). (workspace) ;
183 }