@@ -24,21 +24,6 @@ extern "C"
24
24
25
25
#include " includes/Init.h"
26
26
27
- double * Double (int Length, double val)
28
- {
29
- auto dbl = (double *)malloc (Length * sizeof (double ));
30
-
31
- if (dbl != NULL )
32
- {
33
- for (auto x = 0 ; x < Length; x++)
34
- {
35
- dbl[x] = val;
36
- }
37
- }
38
-
39
- return dbl;
40
- }
41
-
42
27
fftw_complex* Complex (int Length, double val)
43
28
{
44
29
auto dbl = (fftw_complex*)fftw_malloc (Length * sizeof (fftw_complex));
@@ -76,22 +61,6 @@ extern "C"
76
61
return cmplx;
77
62
}
78
63
79
- void Source (fftw_complex** source, int xdim, int ydim)
80
- {
81
- auto size = xdim * ydim;
82
-
83
- *source = Complex (size, 0.0 );
84
-
85
- if (source)
86
- {
87
- // create source field
88
- for (auto index = 0 ; index < size; index++)
89
- {
90
- (*source)[index][Re] = 1.0 ;
91
- }
92
- }
93
- }
94
-
95
64
void Shift (fftw_complex* complex, int sizex, int sizey)
96
65
{
97
66
fftw_complex temp;
@@ -181,28 +150,26 @@ extern "C"
181
150
182
151
// temporary complex arrays to hold intermediate results
183
152
auto result = Complex (size, 0.0 );
184
- auto source = Complex (size, 0 .0 );
153
+ auto source = Complex (size, 1 .0 );
185
154
auto d_temp = Complex (size, 0.0 );
186
155
auto d_result = Complex (size, 0.0 );
187
156
188
- Source (&source, srcx, srcy);
189
-
190
157
// 2D Forward plan
191
158
fwdplan = fftw_plan_dft_2d (srcy, srcx, d_temp, d_result, FFTW_FORWARD, FFTW_MEASURE);
192
159
193
160
// 2D Inverse plan
194
161
invplan = fftw_plan_dft_2d (srcy, srcx, d_temp, d_result, FFTW_BACKWARD, FFTW_MEASURE);
195
162
196
- auto resized = Copy (Input, srcx, srcy);
163
+ auto target = Copy (Input, srcx, srcy);
197
164
198
- Shift (resized , srcx, srcy);
165
+ Shift (target , srcx, srcy);
199
166
200
167
// ---------------------
201
168
// -- GS PHASE --
202
169
// ---------------------
203
170
204
171
// Get initial estimate of the phase
205
- fftw_execute_dft (invplan, resized , d_result);
172
+ fftw_execute_dft (invplan, target , d_result);
206
173
207
174
for (auto iter = 0 ; iter < Ngs; iter++)
208
175
{
@@ -213,7 +180,7 @@ extern "C"
213
180
fftw_execute_dft (fwdplan, d_temp, d_result);
214
181
215
182
// Apply target constraints
216
- ComputePhaseAndMakeComplexField (d_result, resized , d_temp, size);
183
+ ComputePhaseAndMakeComplexField (d_result, target , d_temp, size);
217
184
218
185
// perform backward transform
219
186
fftw_execute_dft (invplan, d_temp, d_result);
@@ -241,7 +208,7 @@ extern "C"
241
208
fftw_cleanup ();
242
209
243
210
// free memory
244
- fftw_free (resized );
211
+ fftw_free (target );
245
212
fftw_free (d_result);
246
213
fftw_free (d_temp);
247
214
fftw_free (result);
0 commit comments