Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-8146: fix fftw failure when using MKL based conda stack #194

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/SincCoeffs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,13 @@ std::shared_ptr<afw::image::Image<PixelT>> calcImageKSpaceReal(double const rad1
int xcen = wid / 2, ycen = wid / 2;
FftShifter fftshift(wid);

boost::shared_array<double> cimg(new double[wid * wid]);
double* c = cimg.get();
boost::shared_array<std::complex<double>> cimg(new std::complex<double>[wid * wid]);
std::complex<double>* c = cimg.get();
// fftplan args: nx, ny, *in, *out, kindx, kindy, flags
// - done in-situ if *in == *out
fftw_plan plan = fftw_plan_r2r_2d(wid, wid, c, c, FFTW_R2HC, FFTW_R2HC, FFTW_ESTIMATE);

fftw_plan plan = fftw_plan_dft_2d(wid, wid, reinterpret_cast<fftw_complex*>(c),
reinterpret_cast<fftw_complex*>(c), FFTW_BACKWARD, FFTW_ESTIMATE);
// compute the k-space values and put them in the cimg array
double const twoPiRad1 = geom::TWOPI * rad1;
double const twoPiRad2 = geom::TWOPI * rad2;
Expand All @@ -451,7 +452,7 @@ std::shared_ptr<afw::image::Image<PixelT>> calcImageKSpaceReal(double const rad1
}
}
int fxy = fftshift.shift(wid / 2);
c[fxy * wid + fxy] = geom::PI * (rad2 * rad2 - rad1 * rad1);
c[fxy * wid + fxy] = {geom::PI * (rad2 * rad2 - rad1 * rad1), 0.};

// perform the fft and clean up after ourselves
fftw_execute(plan);
Expand All @@ -468,7 +469,7 @@ std::shared_ptr<afw::image::Image<PixelT>> calcImageKSpaceReal(double const rad1
// now need to reflect the quadrant we solved to the other three
int fX = iX < hwid ? hwid - iX - 1 : iX - hwid + 1;
int fY = iY < hwid ? hwid - iY - 1 : iY - hwid + 1;
*ptr = static_cast<PixelT>(c[fY * wid + fX] / (wid * wid));
*ptr = static_cast<PixelT>(c[fY * wid + fX].real() / (wid * wid));
iX++;
}
}
Expand Down