Skip to content

Commit 3d33d5f

Browse files
authored
Merge pull request numpy#26359 from mhvk/fft-rfft-n-even-bugfix-replacement
MAINT: Simplify bugfix for even rfft
2 parents 4340733 + 394ffa4 commit 3d33d5f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

numpy/fft/_pocketfft_umath.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ rfft_impl(char **args, npy_intp const *dimensions, npy_intp const *steps,
172172
auto plan = pocketfft::detail::get_plan<pocketfft::detail::pocketfft_r<T>>(npts);
173173
auto buffered = (step_out != sizeof(std::complex<T>));
174174
pocketfft::detail::arr<std::complex<T>> buff(buffered ? nout : 0);
175+
auto nin_used = nin <= npts ? nin : npts;
175176
for (size_t i = 0; i < n_outer; i++, ip += si, fp += sf, op += so) {
176177
std::complex<T> *op_or_buff = buffered ? buff.data() : (std::complex<T> *)op;
177178
/*
@@ -186,12 +187,9 @@ rfft_impl(char **args, npy_intp const *dimensions, npy_intp const *steps,
186187
* create I0=0. Note that copy_input will zero the In component for
187188
* even number of points.
188189
*/
189-
copy_input(ip, step_in, nin, &((T *)op_or_buff)[1], nout*2 - 1);
190+
copy_input(ip, step_in, nin_used, &((T *)op_or_buff)[1], nout*2 - 1);
190191
plan->exec(&((T *)op_or_buff)[1], *(T *)fp, pocketfft::FORWARD);
191192
op_or_buff[0] = op_or_buff[0].imag(); // I0->R0, I0=0
192-
if (!(npts & 1)) {
193-
op_or_buff[nout - 1].imag(0.0);
194-
}
195193
if (buffered) {
196194
copy_output(op_or_buff, op, step_out, nout);
197195
}

0 commit comments

Comments
 (0)