Numeric python question: How do I zero all elements of a matrix 0 ?
Ram Bhamidipaty
ramb at sonic.net
Mon Oct 14 19:10:27 EDT 2002
I have a matrix created with the Numeric package,
I want to keep reusing the same matrix, in order to
do this I need to zero out all the elements.
I know I could write a loop like this:
# my arrays are two dimensional
t = M.shape
for x in range(0,t[0]):
for y in range(0,t[1]):
M[x,y] = 0.0
But I have a feeling that this would be very slow. Is
there a special function that I can use to do this?
Right now I just create new matrices and let the
python garbage collector worry about memory usage - so I am
looking for anything that would be faster.
Thanks for any info.
-Ram
More information about the Python-list
mailing list