parameters: (self, a, size, n_iter, random_state=None)
return_statement: return q
docstring: Computes an orthonormal matrix whose range approximates the range of A.
docstring_summary: Computes an orthonormal matrix whose range approximates the range of A.
docstring_tokens: Computes an orthonormal matrix whose range approximates the range of A .
function: def _random_range_finder(self, a, size, n_iter, random_state=None):
          """Computes an orthonormal matrix whose range approximates the range of A."""
          random_state = self._check_random_status(random_state)
          # Generate normal random vectors.
          q = random_state.normal(size=(a.shape[1], size))
          if a.dtype.kind == "f":
              # Ensure f32 is retained as f32
              q = q.astype(a.dtype, copy=False)
          if n_iter <= 2:
              power_iteration_normalizer = "none"
          else:
              power_iteration_normalizer = "LU"
          # use power iterations with q to further compute the top singular vectors of a in q
          for _ in range(n_iter):
              if power_iteration_normalizer == "none":
                  q = self._safe_dot(a, q)
                  q = self._safe_dot(a.T, q)
              elif power_iteration_normalizer == "LU":
                  q, _ = linalg.lu(self._safe_dot(a, q), permute_l=True)
                  q, _ = linalg.lu(self._safe_dot(a.T, q), permute_l=True)
          # The orthogonal basis is extracted by the linear projection of Q, and the range of a is sampled.
          q, _ = linalg.qr(self._safe_dot(a, q), mode="economic")
          return q
function_tokens: def _random_range_finder ( self , a , size , n_iter , random_state = None ) : random_state = self . _check_random_status ( random_state ) # Generate normal random vectors. q = random_state . normal ( size = ( a . shape [ 1 ] , size ) ) if a . dtype . kind == "f" : # Ensure f32 is retained as f32 q = q . astype ( a . dtype , copy = False ) if n_iter <= 2 : power_iteration_normalizer = "none" else : power_iteration_normalizer = "LU" # use power iterations with q to further compute the top singular vectors of a in q for _ in range ( n_iter ) : if power_iteration_normalizer == "none" : q = self . _safe_dot ( a , q ) q = self . _safe_dot ( a . T , q ) elif power_iteration_normalizer == "LU" : q , _ = linalg . lu ( self . _safe_dot ( a , q ) , permute_l = True ) q , _ = linalg . lu ( self . _safe_dot ( a . T , q ) , permute_l = True ) # The orthogonal basis is extracted by the linear projection of Q, and the range of a is sampled. q , _ = linalg . qr ( self . _safe_dot ( a , q ) , mode = "economic" ) return q