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