From: Charles R H. <cha...@gm...> - 2006-08-28 06:05:31
|
Hi Carlos, On 8/27/06, Carlos Pita <car...@ya...> wrote: > > Hi all! > Is there a more efficient way of creating a constant K-valued array of > size N than: > zeros(N) + K > ? > Maybe something like this: In [12]: a = empty((3,3), dtype=int) In [13]: a.fill(11) In [14]: a Out[14]: array([[11, 11, 11], [11, 11, 11], [11, 11, 11]]) I haven't timed it, so don't know how fast it is. Looking at this makes me think fill should return the array so that one could do something like: a = empty((3,3), dtype=int).fill(10) Chuck |