Compute distance between two trajectories

        Returns
        -------
        numpy.ndarray
343223
def compute_distance(m, l):
        '''
        '''

        if np.shape(m) != np.shape(l):
            raise ValueError("Input matrices are different sizes")
        if np.array_equal(m, l):
            # print("Trajectory %s and %s are equal" % (m, l))
            distance = 0
        else:
            distance = np.array(np.sum(cdist(m, l)), dtype=np.float32)

        return distance
199326
def FindNotNaNBackwards(x, i):
    """"""
    while i >= 0:
        if not np.isnan(x[i]):
            return i
        i -= 1
    return -1
1034766
def _compute_distance_term(self, C, rhypo):
        
        return (C["c2"] * rhypo) + (C["c3"] * np.log10(rhypo))
1090546
def closestDirectDistance(arr, ksize=30, dtype=np.uint16):
    '''
    
    '''

    out = np.zeros_like(arr, dtype=dtype)
    _calc(out, arr, ksize)
    return out
721015
def _jit_pairwise_distances(pos1, pos2):
        
        n1 = pos1.shape[0]
        n2 = pos2.shape[0]
        D = np.empty((n1, n2))

        for i in range(n1):
            for j in range(n2):
                D[i, j] = np.sqrt(((pos1[i] - pos2[j])**2).sum())
        return D
711384
def _distance(coord1, coord2):
    
    xdist = coord1[0] - coord2[0]
    ydist = coord1[1] - coord2[1]
    return sqrt(xdist*xdist + ydist*ydist)
574604
def get_distance_to(self, origin=None, other_atoms=None, sort=False):
        
        if origin is None:
            origin = np.zeros(3)
        elif pd.api.types.is_list_like(origin):
            origin = np.array(origin, dtype='f8')
        else:
            origin = self.loc[origin, ['x', 'y', 'z']]

        if other_atoms is None:
            other_atoms = self.index

        new = self.loc[other_atoms, :].copy()
        norm = np.linalg.norm
        try:
            new['distance'] = norm((new - origin).loc[:, ['x', 'y', 'z']],
                                   axis=1)
        except AttributeError:
            # Happens if molecule consists of only one atom
            new['distance'] = norm((new - origin).loc[:, ['x', 'y', 'z']])
        if sort:
            new.sort_values(by='distance', inplace=True)
        return new
1240509
def distance(r1: 'Region', r2: 'Region'):
        
        return math.sqrt((r2.x - r1.x) ** 2 + (r2.y - r1.y) ** 2)
592499
def neighbor_difference(self):
        """"""
        differences = np.zeros(self.num_neurons)
        num_neighbors = np.zeros(self.num_neurons)

        distance, _ = self.distance_function(self.weights, self.weights)
        for x, y in self.neighbors():
            differences[x] += distance[x, y]
            num_neighbors[x] += 1

        return differences / num_neighbors
950719
def number_of_trajectories(self, stride=None):
        
        """
        if not IteratorState.is_uniform_stride(stride):
            n = len(np.unique(stride[:, 0]))
        else:
            n = self.ntraj
        return n
161925
def _compute_distance_fast(self):
        """"""
        d, m = edit_distance(self.seq1, self.seq2,
                             action_function=self.action_function,
                             test=self.test)
        if self.dist:
            assert d == self.dist
        if self._matches:
            assert m == self._matches
        self.dist = d
        self._matches = m
989980
def _dcorr(y, n2, A, dcov2_xx):
    
    # Pairwise Euclidean distances
    b = squareform(pdist(y, metric='euclidean'))
    # Double centering
    B = b - b.mean(axis=0)[None, :] - b.mean(axis=1)[:, None] + b.mean()
    # Compute squared distance covariances
    dcov2_yy = np.vdot(B, B) / n2
    dcov2_xy = np.vdot(A, B) / n2
    return np.sqrt(dcov2_xy) / np.sqrt(np.sqrt(dcov2_xx) * np.sqrt(dcov2_yy))
1166382
def _compute_distance(self, rup, dists, C):
        
        rval = np.sqrt(dists.repi ** 2 + C['h'] ** 2)
        return C['c1'] * np.log10(rval)
559871
def _compute_distance_scaling(self, C, rhypo):
        
        return C["c"] * np.log10(np.sqrt((rhypo ** 2.) + (C["h"] ** 2.))) +\
            (C["d"] * rhypo)
132305
def distance_to_contact(D, alpha=1):
    

    if callable(alpha):
        distance_function = alpha
    else:
        try:
            a = np.float64(alpha)

            def distance_function(x):
                return 1 / (x ** (1 / a))
        except TypeError:
            print("Alpha parameter must be callable or an array-like")
            raise
        except ZeroDivisionError:
            raise ValueError("Alpha parameter must be non-zero")

    m = np.max(distance_function(D[D != 0]))
    M = np.zeros(D.shape)
    M[D != 0] = distance_function(D[D != 0])
    M[D == 0] = m
    return M
127479
private float distance(MotionEvent event) {
        if (event.getPointerCount() < 2) {
            return 0;
        }
        return PointF.length(event.getX(POINTER1) - event.getX(POINTER2), //
                event.getY(POINTER1) - event.getY(POINTER2));
    }
1195398
def _compute_distance_terms(cls, dists, coeffs):
        
        return - np.log(dists.rhypo) - coeffs['c4']*dists.rhypo