Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.10.2.

librosa.util.dtype_r2c

librosa.util.dtype_r2c(d, *, default=<class 'numpy.complex64'>)[source]

Find the complex numpy dtype corresponding to a real dtype.

This is used to maintain numerical precision and memory footprint when constructing complex arrays from real-valued data (e.g. in a Fourier transform).

A float32 (single-precision) type maps to complex64, while a float64 (double-precision) maps to complex128.

Parameters:
dnp.dtype

The real-valued dtype to convert to complex. If d is a complex type already, it will be returned.

defaultnp.dtype, optional

The default complex target type, if d does not match a known dtype

Returns:
d_cnp.dtype

The complex dtype

Examples

>>> librosa.util.dtype_r2c(np.float32)
dtype('complex64')
>>> librosa.util.dtype_r2c(np.int16)
dtype('complex64')
>>> librosa.util.dtype_r2c(np.complex128)
dtype('complex128')