Skip to content

Commit 1317ce5

Browse files
committed
remove unused code
1 parent 4ba6216 commit 1317ce5

File tree

1 file changed

+6
-39
lines changed

1 file changed

+6
-39
lines changed

gs.cpp

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ extern "C"
2424

2525
#include "includes/Init.h"
2626

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-
4227
fftw_complex* Complex(int Length, double val)
4328
{
4429
auto dbl = (fftw_complex*)fftw_malloc(Length * sizeof(fftw_complex));
@@ -76,22 +61,6 @@ extern "C"
7661
return cmplx;
7762
}
7863

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-
9564
void Shift(fftw_complex* complex, int sizex, int sizey)
9665
{
9766
fftw_complex temp;
@@ -181,28 +150,26 @@ extern "C"
181150

182151
// temporary complex arrays to hold intermediate results
183152
auto result = Complex(size, 0.0);
184-
auto source = Complex(size, 0.0);
153+
auto source = Complex(size, 1.0);
185154
auto d_temp = Complex(size, 0.0);
186155
auto d_result = Complex(size, 0.0);
187156

188-
Source(&source, srcx, srcy);
189-
190157
// 2D Forward plan
191158
fwdplan = fftw_plan_dft_2d(srcy, srcx, d_temp, d_result, FFTW_FORWARD, FFTW_MEASURE);
192159

193160
// 2D Inverse plan
194161
invplan = fftw_plan_dft_2d(srcy, srcx, d_temp, d_result, FFTW_BACKWARD, FFTW_MEASURE);
195162

196-
auto resized = Copy(Input, srcx, srcy);
163+
auto target = Copy(Input, srcx, srcy);
197164

198-
Shift(resized, srcx, srcy);
165+
Shift(target, srcx, srcy);
199166

200167
// ---------------------
201168
// -- GS PHASE --
202169
// ---------------------
203170

204171
// Get initial estimate of the phase
205-
fftw_execute_dft(invplan, resized, d_result);
172+
fftw_execute_dft(invplan, target, d_result);
206173

207174
for (auto iter = 0; iter < Ngs; iter++)
208175
{
@@ -213,7 +180,7 @@ extern "C"
213180
fftw_execute_dft(fwdplan, d_temp, d_result);
214181

215182
// Apply target constraints
216-
ComputePhaseAndMakeComplexField(d_result, resized, d_temp, size);
183+
ComputePhaseAndMakeComplexField(d_result, target, d_temp, size);
217184

218185
// perform backward transform
219186
fftw_execute_dft(invplan, d_temp, d_result);
@@ -241,7 +208,7 @@ extern "C"
241208
fftw_cleanup();
242209

243210
// free memory
244-
fftw_free(resized);
211+
fftw_free(target);
245212
fftw_free(d_result);
246213
fftw_free(d_temp);
247214
fftw_free(result);

0 commit comments

Comments
 (0)