On 2 February 2014 20:58, Mads Ipsen mads.ip...@gmail.com wrote:
ie. bond 0 connects atoms 0 and 5, bond 1 connects atom 0 and 6, etc. In
practical examples, the list can be much larger (N 100.000 connections.
Perhaps you should consider an alternative approach. You could consider it
a
Seconding Jaime; I use this trick in mesh manipulations a lot as well.
There are a lot of graph-type manipulations you can express effectively in
numpy using np.unique and related functionality.
On Sun, Feb 2, 2014 at 11:57 PM, Jaime Fernández del Río
jaime.f...@gmail.com wrote:
Cannot test
I think you'll find the algorithm below to be a lot faster, especially if the
arrays are big. Checking each array index against the list of included or
excluded elements is must slower than simply creating a secondary array and
looking up whether the elements are included or not.
b =
Hi,
Thanks to everybody for all you valuable responses. This approach by
Rick White seems to nail it all down:
b = np.array([
[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 7, 8, 9, 10,
11],
[5, 6, 1, 0, 2, 7, 3, 8, 1, 4, 9, 2, 10, 5, 3, 4, 11, 0, 0, 1, 2, 3, 4, 5]
])
a
Hi,
I have run into a potential 'for loop' bottleneck. Let me outline:
The following array describes bonds (connections) in a benzene molecule
b = [[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 7,
8, 9, 10, 11],
[5, 6, 1, 0, 2, 7, 3, 8, 1, 4, 9, 2, 10, 5, 3, 4, 11, 0,
On Sun, Feb 2, 2014 at 2:58 PM, Mads Ipsen mads.ip...@gmail.com wrote:
Since atoms [1,2,3,7,8] have been
deleted, the remaining atoms with indices larger than the deleted atoms
must be decremented.
Let
x
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
and
i =
Cannot test right now, but np.unique(b, return_inverse=True)[1].reshape(2,
-1) should do what you are after, I think.
On Feb 2, 2014 11:58 AM, Mads Ipsen mads.ip...@gmail.com wrote:
Hi,
I have run into a potential 'for loop' bottleneck. Let me outline:
The following array describes bonds