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