[Numpy-discussion] partial computations
Thu Apr 12 07:51:17 CDT 2012
On Wed, Apr 11, 2012 at 11:38 PM, santhu kumar <email@example.com> wrote:
> Hello all,
> I am trying to optimise a code and want your suggestions.
> A : - NX3 matrix (coordinates of N points)
> After performing pairwise distance computations(called pdist) between
> these points, depending upon a condition that the distance is in, I would
> perform further computations.
> Most of the computations require schur products (element by element) of
> NXN matrices with each other and then computing either the coloumn sum or
> row sum.
> As N goes to be large, these computations are taking some time (0.7 secs)
> which is not much generally but since this is being called many times, it
> acts as a bottleneck.
> I want to leverage on the fact that many of the NXN computations are not
> going to be used, or would be set to zero (if the pdist is greater than
> some minimum distance).
> How do i achieve it ?? Is masked array the elegant solution? Would it save
> me time?
You might want to consider using scipy.spatial's KDTree as a way to
efficiently find all points that are within a specified distance from each
other. Then, using those pairs, load up a sparse array with only the
relevant pairs. It should save in computation and memory as well.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion