parameters: (M, k, k_skip=1, eigen_solver='arpack', tol=1E-6, max_iter=100,
                 random_state=None)
docstring: Find the null space of a matrix M.
  
      Parameters
      ----------
      M : {array, matrix, sparse matrix, LinearOperator}
          Input covariance matrix: should be symmetric positive semi-definite
  
      k : integer
          Number of eigenvalues/vectors to return
  
      k_skip : integer, optional
          Number of low eigenvalues to skip.
  
      eigen_solver : string, {'auto', 'arpack', 'dense'}
          auto : algorithm will attempt to choose the best method for input data
          arpack : use arnoldi iteration in shift-invert mode.
                      For this method, M may be a dense matrix, sparse matrix,
                      or general linear operator.
                      Warning: ARPACK can be unstable for some problems.  It is
                      best to try several random seeds in order to check results.
          dense  : use standard dense matrix operations for the eigenvalue
                      decomposition.  For this method, M must be an array
                      or matrix type.  This method should be avoided for
                      large problems.
  
      tol : float, optional
          Tolerance for 'arpack' method.
          Not used if eigen_solver=='dense'.
  
      max_iter : int
          Maximum number of iterations for 'arpack' method.
          Not used if eigen_solver=='dense'
  
      random_state : int, RandomState instance or None, optional (default=None)
          If int, random_state is the seed used by the random number generator;
          If RandomState instance, random_state is the random number generator;
          If None, the random number generator is the RandomState instance used
          by `np.random`. Used when ``solver`` == 'arpack'.
docstring_summary: Find the null space of a matrix M.
docstring_tokens: Find the null space of a matrix M .
function: def null_space(M, k, k_skip=1, eigen_solver='arpack', tol=1E-6, max_iter=100,
                 random_state=None):
      """
      Find the null space of a matrix M.
  
      Parameters
      ----------
      M : {array, matrix, sparse matrix, LinearOperator}
          Input covariance matrix: should be symmetric positive semi-definite
  
      k : integer
          Number of eigenvalues/vectors to return
  
      k_skip : integer, optional
          Number of low eigenvalues to skip.
  
      eigen_solver : string, {'auto', 'arpack', 'dense'}
          auto : algorithm will attempt to choose the best method for input data
          arpack : use arnoldi iteration in shift-invert mode.
                      For this method, M may be a dense matrix, sparse matrix,
                      or general linear operator.
                      Warning: ARPACK can be unstable for some problems.  It is
                      best to try several random seeds in order to check results.
          dense  : use standard dense matrix operations for the eigenvalue
                      decomposition.  For this method, M must be an array
                      or matrix type.  This method should be avoided for
                      large problems.
  
      tol : float, optional
          Tolerance for 'arpack' method.
          Not used if eigen_solver=='dense'.
  
      max_iter : int
          Maximum number of iterations for 'arpack' method.
          Not used if eigen_solver=='dense'
  
      random_state : int, RandomState instance or None, optional (default=None)
          If int, random_state is the seed used by the random number generator;
          If RandomState instance, random_state is the random number generator;
          If None, the random number generator is the RandomState instance used
          by `np.random`. Used when ``solver`` == 'arpack'.
  
      """
      if eigen_solver == 'auto':
          if M.shape[0] > 200 and k + k_skip < 10:
              eigen_solver = 'arpack'
          else:
              eigen_solver = 'dense'
  
      if eigen_solver == 'arpack':
          random_state = check_random_state(random_state)
          # initialize with [-1,1] as in ARPACK
          v0 = random_state.uniform(-1, 1, M.shape[0])
          try:
              eigen_values, eigen_vectors = eigsh(M, k + k_skip, sigma=0.0,
                                                  tol=tol, maxiter=max_iter,
                                                  v0=v0)
          except RuntimeError as msg:
              raise ValueError("Error in determining null-space with ARPACK. "
                               "Error message: '%s'. "
                               "Note that method='arpack' can fail when the "
                               "weight matrix is singular or otherwise "
                               "ill-behaved.  method='dense' is recommended. "
                               "See online documentation for more information."
                               % msg)
  
          return eigen_vectors[:, k_skip:], np.sum(eigen_values[k_skip:])
      elif eigen_solver == 'dense':
          if hasattr(M, 'toarray'):
              M = M.toarray()
          eigen_values, eigen_vectors = eigh(
              M, eigvals=(k_skip, k + k_skip - 1), overwrite_a=True)
          index = np.argsort(np.abs(eigen_values))
          return eigen_vectors[:, index], np.sum(eigen_values)
      else:
          raise ValueError("Unrecognized eigen_solver '%s'" % eigen_solver)
function_tokens: def null_space ( M , k , k_skip = 1 , eigen_solver = 'arpack' , tol = 1E-6 , max_iter = 100 , random_state = None ) : if eigen_solver == 'auto' : if M . shape [ 0 ] > 200 and k + k_skip < 10 : eigen_solver = 'arpack' else : eigen_solver = 'dense' if eigen_solver == 'arpack' : random_state = check_random_state ( random_state ) # initialize with [-1,1] as in ARPACK v0 = random_state . uniform ( - 1 , 1 , M . shape [ 0 ] ) try : eigen_values , eigen_vectors = eigsh ( M , k + k_skip , sigma = 0.0 , tol = tol , maxiter = max_iter , v0 = v0 ) except RuntimeError as msg : raise ValueError ( "Error in determining null-space with ARPACK. " "Error message: '%s'. " "Note that method='arpack' can fail when the " "weight matrix is singular or otherwise " "ill-behaved.  method='dense' is recommended. " "See online documentation for more information." % msg ) return eigen_vectors [ : , k_skip : ] , np . sum ( eigen_values [ k_skip : ] ) elif eigen_solver == 'dense' : if hasattr ( M , 'toarray' ) : M = M . toarray ( ) eigen_values , eigen_vectors = eigh ( M , eigvals = ( k_skip , k + k_skip - 1 ) , overwrite_a = True ) index = np . argsort ( np . abs ( eigen_values ) ) return eigen_vectors [ : , index ] , np . sum ( eigen_values ) else : raise ValueError ( "Unrecognized eigen_solver '%s'" % eigen_solver )