I have a Python nonpoint array that I am using for a simulation with toroidal boundary conditions
For example, when I'm using Python Take advantage of negative indexing of Using your modules is equivalent to your version: i = N-1 ,
i + 1 becomes 0 on the border.
a [(i + 1)% n, (j + 1)% n] to reach out to the nearest neighbors, so the index wraps around itself .
a [(i + 1) -n, (j + 1) -n]
& gt; & Gt; & Gt; A = [1, 2, 3, 4, 5, 6, 7, 8, 9] & gt; & Gt; & Gt; In range (lane (a)): print (one [(i + 1)% lane (a)], a [i-1-len (a)]) 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 1 1 If the boundaries are smaller than the length of the axis of the array, then you can take one piece of the array with the right borders (which should not be too much in Numpy Use memory because it will have only one view in the original array) and then use the negative indexing method.
No comments:
Post a Comment