Skip to content

Accuracy of real FFTs is really bad #11886

Closed

Description

@mreineck

When using numpy's real-valued FFT implementation on arrays with nearly prime length, the results are very inaccurate (this was already noticed, but not fixed, in #10625)

To reproduce, run, e.g.:

from __future__ import print_function
import numpy as np

for i in range(2, 4096):
    a=np.random.rand(i)-0.5
    b=np.fft.irfft(np.fft.rfft(a),i)
    err = np.linalg.norm(a-b)/np.linalg.norm(a)
    if err>1e-12:
        b2 = np.fft.ifft(np.fft.fft(a))
        err2 = np.linalg.norm(a-b2)/np.linalg.norm(a)
        print("Length: ", i,": error measure",err," (error measure of complex FFT:", err2,")")

(NB: the FFT implementation proposed in #11885 does not have this problem)

Activity

  1. mreineck commented on Apr 17, 2019

    @mreineck
    ContributorAuthor

    Should be fixed in 1.17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions