[Numpy-discussion] Optimization suggestion sought
Enzo Michelangeli
enzomich at gmail.com
Sun Dec 26 03:51:57 EST 2010
For a pivoted algorithm, I have to perform an operation that in fully
vectorized form can be expressed as:
pivot = tableau[locat,:]/tableau[locat,cand]
tableau -= tableau[:,cand:cand+1]*pivot
tableau[locat,:] = pivot
tableau is a rather large bidimensional array, and I'd like to avoid the
allocation of a temporary array of the same size holding the result of the
right-hand side expression in the second line of code (the outer product of
tableau[:,cand] and pivot). On the other hand, if I replace that line with:
for i in xrange(tableau.shape[0]):
tableau[i] -= tableau[i,cand]*pivot
...I incur some CPU overhead for the "for" loop -- and this part of code is
the botteneck of the whole algorithm. Is there any smarter (i.e., more
time-efficient) way of achieving my goal?
TIA --
Enzo
More information about the NumPy-Discussion
mailing list