Skip to content

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

Closed
@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