El dt 17 de 04 del 2007 a les 20:58 +0200, en/na Miquel Poch va escriure: > Hi, > > I've found the next expression write it in Matlab, > > Rtx = sqrt(Rt); > > Rtx is a matrix, and that's why I need sqrt() to operate elementwise. > I've read NumPy tutorial, and I know it's possible, > > A set of this functions, has been provided wich optimize certain kinds > of calculations on arrays. Most of this functions, such as sin, cos > and sqrt are unary functions wich operate elementwise. [Numerical > Python, pg. 13] > > but I don't know who to do it. The next error appear when I execute > the code, > > ''' exceptions.TypeError : only length-1 arrays can be converted to > Python scalars ''
What are you doing? Operating element-wise is one of the most elementary things that you can do with NumPy: In [3]:a=numpy.array([[1,2],[3,4]]) In [4]:a Out[4]: array([[1, 2], [3, 4]]) In [5]:numpy.sqrt(a) Out[5]: array([[ 1. , 1.41421356], [ 1.73205081, 2. ]]) Salut, -- Francesc Altet | Be careful about using the following code -- Carabos Coop. V. | I've only proven that it works, www.carabos.com | I haven't tested it. -- Donald Knuth _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion