Changeset 721 for trunk/src/space.py

Show
Ignore:
Timestamp:
03/03/10 10:41:30 (2 years ago)
Author:
pierre
Message:

Speed up the DistanceDependentProbabilityConnector? in parallel in the new implementation, by computing only distances that will be used by the nodes. Spot also a bug, not fixed yet, with the positions in parallel. They are not correctly assigned by defaults

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/space.py

    r712 r721  
    5353        self.offset = offset 
    5454         
    55     def distances(self, A, B): 
     55    def distances(self, A, B, post_mask=None): 
    5656        """ 
    5757        Calculate the distance matrix between two sets of coordinates, given 
     
    6666        d = numpy.zeros((A.shape[1], B.shape[1]), dtype=A.dtype) 
    6767        for axis in self.axes: 
    68             diff2 = A[axis,:,None] - B[axis,:] 
     68            diff2 = A[axis,:,None] - B[axis, post_mask] 
    6969            if self.periodic_boundaries is not None: 
    7070                boundaries = self.periodic_boundaries[axis] 
    7171                if boundaries is not None: 
    7272                    range = boundaries[1]-boundaries[0] 
    73                     ad2 = abs(diff2) 
     73                    ad2   = abs(diff2) 
    7474                    diff2 = numpy.minimum(ad2, range-ad2) 
    7575            diff2 **= 2 
    76             d += diff2 
    77         numpy.sqrt(d, d) 
     76            d[:,post_mask] += diff2 
     77        numpy.sqrt(d[:,post_mask], d[:,post_mask]) 
    7878        return d