[Numpy-discussion] simple rectangular grid
Robert Kern
robert.kern@gmail....
Thu Apr 15 13:49:09 CDT 2010
On Thu, Apr 15, 2010 at 13:42, Neal Becker <ndbecker2@gmail.com> wrote:
> Is there a simple way to create a rectangular grid, like this loopy code:
> (This is for a QAM256 constellation, btw):
>
> import numpy as np
>
> u = np.arange (-7.5, 8)
>
> const = np.empty ((16,16), dtype=complex)
>
> for ix in range (16):
> for iy in range (16):
> const[ix, iy] = u[ix] + 1j*u[iy]
In [7]: real, imag = np.mgrid[-7.5:7.5:16j, -7.5:7.5:16j]
In [8]: const = real + 1j * imag
--
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