Changeset 721 for trunk/src/space.py
- Timestamp:
- 03/03/10 10:41:30 (2 years ago)
- Files:
-
- 1 modified
-
trunk/src/space.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/space.py
r712 r721 53 53 self.offset = offset 54 54 55 def distances(self, A, B ):55 def distances(self, A, B, post_mask=None): 56 56 """ 57 57 Calculate the distance matrix between two sets of coordinates, given … … 66 66 d = numpy.zeros((A.shape[1], B.shape[1]), dtype=A.dtype) 67 67 for axis in self.axes: 68 diff2 = A[axis,:,None] - B[axis, :]68 diff2 = A[axis,:,None] - B[axis, post_mask] 69 69 if self.periodic_boundaries is not None: 70 70 boundaries = self.periodic_boundaries[axis] 71 71 if boundaries is not None: 72 72 range = boundaries[1]-boundaries[0] 73 ad2 = abs(diff2)73 ad2 = abs(diff2) 74 74 diff2 = numpy.minimum(ad2, range-ad2) 75 75 diff2 **= 2 76 d += diff277 numpy.sqrt(d , d)76 d[:,post_mask] += diff2 77 numpy.sqrt(d[:,post_mask], d[:,post_mask]) 78 78 return d
