Skip to content

Commit

Permalink
Merge pull request #26359 from mhvk/fft-rfft-n-even-bugfix-replacement
Browse files Browse the repository at this point in the history
MAINT: Simplify bugfix for even rfft
  • Loading branch information
charris committed Apr 27, 2024
2 parents 4340733 + 394ffa4 commit 3d33d5f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions numpy/fft/_pocketfft_umath.cpp
Expand Up @@ -172,6 +172,7 @@ rfft_impl(char **args, npy_intp const *dimensions, npy_intp const *steps,
auto plan = pocketfft::detail::get_plan<pocketfft::detail::pocketfft_r<T>>(npts);
auto buffered = (step_out != sizeof(std::complex<T>));
pocketfft::detail::arr<std::complex<T>> buff(buffered ? nout : 0);
auto nin_used = nin <= npts ? nin : npts;
for (size_t i = 0; i < n_outer; i++, ip += si, fp += sf, op += so) {
std::complex<T> *op_or_buff = buffered ? buff.data() : (std::complex<T> *)op;
/*
Expand All @@ -186,12 +187,9 @@ rfft_impl(char **args, npy_intp const *dimensions, npy_intp const *steps,
* create I0=0. Note that copy_input will zero the In component for
* even number of points.
*/
copy_input(ip, step_in, nin, &((T *)op_or_buff)[1], nout*2 - 1);
copy_input(ip, step_in, nin_used, &((T *)op_or_buff)[1], nout*2 - 1);
plan->exec(&((T *)op_or_buff)[1], *(T *)fp, pocketfft::FORWARD);
op_or_buff[0] = op_or_buff[0].imag(); // I0->R0, I0=0
if (!(npts & 1)) {
op_or_buff[nout - 1].imag(0.0);
}
if (buffered) {
copy_output(op_or_buff, op, step_out, nout);
}
Expand Down

0 comments on commit 3d33d5f

Please sign in to comment.