Debian Codegraph @

external/gsl/gsl_fft__c_init.c

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