On Fri, Jun 3, 2011 at 13:46, Neal Becker <[email protected]> wrote: > Can I arrange to reinterpret an array of complex of length N as an array of > float of length 2N, and vice-versa? If so, how?
[~] |1> carr = np.arange(10, dtype=complex) [~] |2> carr array([ 0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 5.+0.j, 6.+0.j, 7.+0.j, 8.+0.j, 9.+0.j]) [~] |3> carr.view(float) array([ 0., 0., 1., 0., 2., 0., 3., 0., 4., 0., 5., 0., 6., 0., 7., 0., 8., 0., 9., 0.]) [~] |4> _.view(complex) array([ 0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 5.+0.j, 6.+0.j, 7.+0.j, 8.+0.j, 9.+0.j]) -- 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 _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
