[Numpy-discussion] convert pair of real arrays -> cmplx
Robert Kern
robert.kern@gmail....
Wed Nov 19 14:01:19 CST 2008
On Wed, Nov 19, 2008 at 07:15, Neal Becker <ndbecker2@gmail.com> wrote:
> What's the best way to convert a pair of real arrays representing real and imag parts to a complex array?
What do you mean by "best"? Easiest to type? Easiest to read? Fastest?
Memory efficient?
Ideally, they'd all be the same, but alas, they are not. Here are two
possibilities:
z = real +1j*imag
z = np.empty(real.shape, complex)
z.real = real
z.imag = imag
You can wrap the latter into a function, and then you probably would
have the best of both worlds.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion
mailing list