Hi, Bob,
 
Thanks. This solution works great. It really helps me a lot.
 
Frank

> Date: Fri, 30 Jan 2009 23:08:35 -0600
> From: robert.kern@gmail.com
> To: numpy-discussion@scipy.org
> Subject: Re: [Numpy-discussion] help on fast slicing on a grid
>
> On Fri, Jan 30, 2009 at 22:41, frank wang <f.yw@hotmail.com> wrote:
> > Thanks for the correction. I will learn the ravel() function since I do not
> > know it. Moving from Matlab world into python is tricky sometime.
> >
> > Your output
> > In [22]: out
> >> Out[22]: array([ 1.+3.j, -5.+9.j])
> >>
> >> In [23]: error
> >> Out[23]: array([ 0.4-0.3j, 0.1-0.7j])
> >
> > are correct answer.
> >
> > However, if my data set is large, this solution takes long time to run. Are
> > there any python/numpy magic to speed it up?
>
> from numpy import *
>
> a = arange(-15,16,2)
> cnstl = a[:,newaxis] + 1j*a
> cnstl = cnstl.ravel()
> X = array([1.4 + 1j*2.7, -3.9 + 1j*8.3])
>
> out = around((X + 1+1j) / 2.0) * 2.0 - (1+1j)
> error = X - out
>
> print out
> print error
>
> --
> 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
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion



Windows Live™ Hotmail®:…more than just e-mail. Check it out.