[Numpy-discussion] Extend ldexp to handle complex inputs

2024-09-25 Thread Carlos Martin
Currently, [ldexp](https://numpy.org/doc/stable/reference/generated/numpy.ldexp.html) throws a TypeError on a complex input: ```python3 import numpy as np def naive_ldexp(x, n): return x * 2**n def new_ldexp(x, n): if np.iscomplex(x): y = np.empty_like(x) y.real = np.ld

[Numpy-discussion] Re: Extend ldexp to handle complex inputs

2024-09-25 Thread Marten van Kerkwijk
Probably good to think first what the inverse function, np.frexp, should do for complex numbers. I guess the choices are: 1. Remove the largest exponent of real/imaginary, and give a complex mantissa, in which only one of the real or imaginary components is guaranteed to have its absolute va