Skip to content

np.fft.fft always returns np.complex128 regardless of input type #17801

@kyjohnso

Description

@kyjohnso

np.fft.fft returns type np.complex128 regardless of input type. If the input type is np.complex64 returning a complex128 array can have a huge effect on system memory and type casting back with asarray is costly for large arrays.

Reproducing code example:

import numpy as np
x = np.random.multivariate_normal([0,0],[[1,0],[0,1]],(1024)).dot([1,1j])
x = np.asarray(x,dtype=np.complex64)
print("dtype of x is: {}".format(x.dtype))
X = np.fft.fft(x)
print("dtype of X is: {}".format(X.dtype))
dtype of x is: complex64
dtype of X is: complex128

Expected Behaviour

I would expect np.fft.fft to return the same type (for complex to complex) as the input, or allow control of the return type.

NumPy/Python version information:

1.19.4 3.8.6 (default, Sep 25 2020, 09:36:53)
[GCC 10.2.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy