parameters: (x, y, p=2, threshold=1000000)
docstring: Compute the distance matrix.
  
      Returns the matrix of all pair-wise distances.
  
      Parameters
      ----------
      x : (M, K) array_like
          Matrix of M vectors in K dimensions.
      y : (N, K) array_like
          Matrix of N vectors in K dimensions.
      p : float, 1 <= p <= infinity
          Which Minkowski p-norm to use.
      threshold : positive int
          If ``M * N * K`` > `threshold`, algorithm uses a Python loop instead
          of large temporary arrays.
  
      Returns
      -------
      result : (M, N) ndarray
          Matrix containing the distance from every vector in `x` to every vector
          in `y`.
  
      Examples
      --------
      >>> from scipy.spatial import distance_matrix
      >>> distance_matrix([[0,0],[0,1]], [[1,0],[1,1]])
      array([[ 1.        ,  1.41421356],
             [ 1.41421356,  1.        ]])
docstring_summary: Compute the distance matrix.
docstring_tokens: Compute the distance matrix .
function: def distance_matrix(x, y, p=2, threshold=1000000):
      """
      Compute the distance matrix.
  
      Returns the matrix of all pair-wise distances.
  
      Parameters
      ----------
      x : (M, K) array_like
          Matrix of M vectors in K dimensions.
      y : (N, K) array_like
          Matrix of N vectors in K dimensions.
      p : float, 1 <= p <= infinity
          Which Minkowski p-norm to use.
      threshold : positive int
          If ``M * N * K`` > `threshold`, algorithm uses a Python loop instead
          of large temporary arrays.
  
      Returns
      -------
      result : (M, N) ndarray
          Matrix containing the distance from every vector in `x` to every vector
          in `y`.
  
      Examples
      --------
      >>> from scipy.spatial import distance_matrix
      >>> distance_matrix([[0,0],[0,1]], [[1,0],[1,1]])
      array([[ 1.        ,  1.41421356],
             [ 1.41421356,  1.        ]])
  
      """
  
      x = np.asarray(x)
      m, k = x.shape
      y = np.asarray(y)
      n, kk = y.shape
  
      if k != kk:
          raise ValueError("x contains %d-dimensional vectors but y contains %d-dimensional vectors" % (k, kk))
  
      if m*n*k <= threshold:
          return minkowski_distance(x[:,np.newaxis,:],y[np.newaxis,:,:],p)
      else:
          result = np.empty((m,n),dtype=float)  # FIXME: figure out the best dtype
          if m < n:
              for i in range(m):
                  result[i,:] = minkowski_distance(x[i],y,p)
          else:
              for j in range(n):
                  result[:,j] = minkowski_distance(x,y[j],p)
          return result
function_tokens: def distance_matrix ( x , y , p = 2 , threshold = 1000000 ) : x = np . asarray ( x ) m , k = x . shape y = np . asarray ( y ) n , kk = y . shape if k != kk : raise ValueError ( "x contains %d-dimensional vectors but y contains %d-dimensional vectors" % ( k , kk ) ) if m * n * k <= threshold : return minkowski_distance ( x [ : , np . newaxis , : ] , y [ np . newaxis , : , : ] , p ) else : result = np . empty ( ( m , n ) , dtype = float ) # FIXME: figure out the best dtype if m < n : for i in range ( m ) : result [ i , : ] = minkowski_distance ( x [ i ] , y , p ) else : for j in range ( n ) : result [ : , j ] = minkowski_distance ( x , y [ j ] , p ) return result