code: def get_spec_rad(self, tolerance=1e-6, max_iter=20, extra_factor=1.0):
          
  
          # Set (or reset) values of x.
          x_old = self._set_initial_x()
  
          # Iterate until the L2 norm of x converges.
          for i in range(max_iter):
  
              x_old_norm = np.linalg.norm(x_old)
  
              x_new = self._operator(x_old) / x_old_norm
  
              x_new_norm = np.linalg.norm(x_new)
  
              if(np.abs(x_new_norm - x_old_norm) < tolerance):
                  if self._verbose:
                      print(' - Power Method converged after %d iterations!' %
                            (i + 1))
                  break
  
              elif i == max_iter - 1 and self._verbose:
                  print(' - Power Method did not converge after %d '
                        'iterations!' % max_iter)
  
              np.copyto(x_old, x_new)
  
          self.spec_rad = x_new_norm * extra_factor
          self.inv_spec_rad = 1.0 / self.spec_rad
docs: Get spectral radius
  
          This method calculates the spectral radius
  
          Parameters
          ----------
          tolerance : float, optional
              Tolerance threshold for convergence (default is "1e-6")
          max_iter : int, optional
              Maximum number of iterations (default is 20)
          extra_factor : float, optional
              Extra multiplicative factor for calculating the spectral radius
              (default is 1.0)