How to accumulate a matrix in a loop efficiently

Huaiyu Zhu hzhu at users.sourceforge.net
Fri Sep 29 20:29:42 EDT 2000


This is a NumPy question:

Say I have a loop that gives me a one dim array at a time.  What would be
the most efficient way to accumulate it?  Is the following a good way to do
it? 

>>> from Numeric import *
>>> a = []
>>> for i in range(3): a.append(arange(5))
... 
>>> array(a)
array([[0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4]])
	      
What if I get a (1, n) shaped array at each step?  

Huaiyu

-- 
Huaiyu Zhu                       hzhu at users.sourceforge.net
Matrix for Python Project        http://MatPy.sourceforge.net 



More information about the Python-list mailing list