[Numpy-discussion] huge array calculation speed
Charles R Harris
charlesr.harris@gmail....
Thu Jul 10 12:35:41 CDT 2008
On Thu, Jul 10, 2008 at 10:38 AM, Dan Lussier <dtlussier@gmail.com> wrote:
> Hello,
>
> I am relatively new to numpy and am having trouble with the speed of
> a specific array based calculation that I'm trying to do.
>
> What I'm trying to do is to calculate the total total potential
> energy and coordination number of each atom within a relatively large
> simulation. Each atom is at a position (x,y,z) given by a row in a
> large array (approximately 1e6 by 3) and presently I have no
> information about its nearest neighbours so each its position must be
> checked against all others before cutting the list down prior to
> calculating the energy.
>
This looks to be O(n^2) and might well be the bottle neck. There are various
ways to speed up such things but more information would help determine the
method, i.e., is this operation within a loop so that the values change a
lot. However, one quick thing to try is a sort on one of the coordinates so
you only need to check a subset of the vectors. Searchsorted could be useful
here also.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080710/00741e96/attachment.html
More information about the Numpy-discussion
mailing list