MCPcopy Create free account
hub / github.com/numpy/numpy / irfft

Function irfft

numpy/fft/_pocketfft.py:414–514  ·  view source on GitHub ↗

Computes the inverse of `rfft`. This function computes the inverse of the one-dimensional *n*-point discrete Fourier Transform of real input computed by `rfft`. In other words, ``irfft(rfft(a), len(a)) == a`` to within numerical accuracy. (See Notes below for why ``len(a)`` is

(a, n=None, axis=-1, norm=None)

Source from the content-addressed store, hash-verified

412
413@array_function_dispatch(_fft_dispatcher)
414def irfft(a, n=None, axis=-1, norm=None):
415 """
416 Computes the inverse of `rfft`.
417
418 This function computes the inverse of the one-dimensional *n*-point
419 discrete Fourier Transform of real input computed by `rfft`.
420 In other words, ``irfft(rfft(a), len(a)) == a`` to within numerical
421 accuracy. (See Notes below for why ``len(a)`` is necessary here.)
422
423 The input is expected to be in the form returned by `rfft`, i.e. the
424 real zero-frequency term followed by the complex positive frequency terms
425 in order of increasing frequency. Since the discrete Fourier Transform of
426 real input is Hermitian-symmetric, the negative frequency terms are taken
427 to be the complex conjugates of the corresponding positive frequency terms.
428
429 Parameters
430 ----------
431 a : array_like
432 The input array.
433 n : int, optional
434 Length of the transformed axis of the output.
435 For `n` output points, ``n//2+1`` input points are necessary. If the
436 input is longer than this, it is cropped. If it is shorter than this,
437 it is padded with zeros. If `n` is not given, it is taken to be
438 ``2*(m-1)`` where ``m`` is the length of the input along the axis
439 specified by `axis`.
440 axis : int, optional
441 Axis over which to compute the inverse FFT. If not given, the last
442 axis is used.
443 norm : {"backward", "ortho", "forward"}, optional
444 .. versionadded:: 1.10.0
445
446 Normalization mode (see `numpy.fft`). Default is "backward".
447 Indicates which direction of the forward/backward pair of transforms
448 is scaled and with what normalization factor.
449
450 .. versionadded:: 1.20.0
451
452 The "backward", "forward" values were added.
453
454 Returns
455 -------
456 out : ndarray
457 The truncated or zero-padded input, transformed along the axis
458 indicated by `axis`, or the last one if `axis` is not specified.
459 The length of the transformed axis is `n`, or, if `n` is not given,
460 ``2*(m-1)`` where ``m`` is the length of the transformed axis of the
461 input. To get an odd number of output points, `n` must be specified.
462
463 Raises
464 ------
465 IndexError
466 If `axis` is not a valid axis of `a`.
467
468 See Also
469 --------
470 numpy.fft : For definition of the DFT and conventions used.
471 rfft : The one-dimensional FFT of real input, of which `irfft` is inverse.

Callers 2

hfftFunction · 0.85
irfftnFunction · 0.85

Calls 3

asarrayFunction · 0.90
_get_backward_normFunction · 0.85
_raw_fftFunction · 0.85

Tested by

no test coverage detected