
'''simple docstring'''



import numpy as np
def    lowerCAmelCase_	(				SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ = 1e-12    ,      SCREAMING_SNAKE_CASE_ = 1_00    ,      )     ->     tuple[float, np.ndarray]:




   """simple docstring"""
   assert np.shape(SCREAMING_SNAKE_CASE_						)[0] == np.shape(SCREAMING_SNAKE_CASE_						)[1]
   # Ensure proper dimensionality.
   assert np.shape(SCREAMING_SNAKE_CASE_						)[0] == np.shape(SCREAMING_SNAKE_CASE_						)[0]
   # Ensure inputs are either both complex or both real
   assert np.iscomplexobj(SCREAMING_SNAKE_CASE_						) == np.iscomplexobj(SCREAMING_SNAKE_CASE_						)
   _SCREAMING_SNAKE_CASE      =				np.iscomplexobj(SCREAMING_SNAKE_CASE_						)
   if is_complex:
      # Ensure complex input_matrix is Hermitian
      assert np.array_equal(SCREAMING_SNAKE_CASE_    ,      input_matrix.conj().T						)

   # Set convergence to False. Will define convergence when we exceed max_iterations
   # or when we have small changes from one iteration to next.

   _SCREAMING_SNAKE_CASE      =				False
   _SCREAMING_SNAKE_CASE      =				0
   _SCREAMING_SNAKE_CASE      =				0
   _SCREAMING_SNAKE_CASE      =				1e12

   while not convergence:
      # Multiple matrix by the vector.
      _SCREAMING_SNAKE_CASE      =				np.dot(SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_						)
      # Normalize the resulting output vector.
      _SCREAMING_SNAKE_CASE      =				w / np.linalg.norm(SCREAMING_SNAKE_CASE_						)
      # Find rayleigh quotient
      # (faster than usual b/c we know vector is normalized already)
      _SCREAMING_SNAKE_CASE      =				vector.conj().T if is_complex else vector.T
      _SCREAMING_SNAKE_CASE      =				np.dot(SCREAMING_SNAKE_CASE_    ,      np.dot(SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_						)						)

      # Check convergence.
      _SCREAMING_SNAKE_CASE      =				np.abs(lambda_ - lambda_previous						) / lambda_
      iterations += 1

      if error <= error_tol or iterations >= max_iterations:
         _SCREAMING_SNAKE_CASE      =				True

      _SCREAMING_SNAKE_CASE      =				lambda_

   if is_complex:
      _SCREAMING_SNAKE_CASE      =				np.real(lambda_						)

   return lambda_, vector
def    lowerCAmelCase_	(				)     ->     None:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE      =				np.array([[41, 4, 20], [4, 26, 30], [20, 30, 50]]						)
   _SCREAMING_SNAKE_CASE      =				np.array([41, 4, 20]						)
   _SCREAMING_SNAKE_CASE      =				real_input_matrix.astype(np.complexaaa						)
   _SCREAMING_SNAKE_CASE      =				np.triu(1j * complex_input_matrix    ,      1						)
   complex_input_matrix += imag_matrix
   complex_input_matrix += -1 * imag_matrix.T
   _SCREAMING_SNAKE_CASE      =				np.array([41, 4, 20]						).astype(np.complexaaa						)

   for problem_type in ["real", "complex"]:
      if problem_type == "real":
         _SCREAMING_SNAKE_CASE      =				real_input_matrix
         _SCREAMING_SNAKE_CASE      =				real_vector
      elif problem_type == "complex":
         _SCREAMING_SNAKE_CASE      =				complex_input_matrix
         _SCREAMING_SNAKE_CASE      =				complex_vector

      # Our implementation.
      _SCREAMING_SNAKE_CASE ,							_SCREAMING_SNAKE_CASE      =				power_iteration(SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_						)

      # Numpy implementation.

      # Get eigenvalues and eigenvectors using built-in numpy
      # eigh (eigh used for symmetric or hermetian matrices).
      _SCREAMING_SNAKE_CASE ,							_SCREAMING_SNAKE_CASE      =				np.linalg.eigh(SCREAMING_SNAKE_CASE_						)
      # Last eigenvalue is the maximum one.
      _SCREAMING_SNAKE_CASE      =				eigen_values[-1]
      # Last column in this matrix is eigenvector corresponding to largest eigenvalue.
      _SCREAMING_SNAKE_CASE      =				eigen_vectors[:, -1]

      # Check our implementation and numpy gives close answers.
      assert np.abs(eigen_value - eigen_value_max						) <= 1e-6
      # Take absolute values element wise of each eigenvector.
      # as they are only unique to a minus sign.
      assert np.linalg.norm(np.abs(SCREAMING_SNAKE_CASE_						) - np.abs(SCREAMING_SNAKE_CASE_						)						) <= 1e-6


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     test_power_iteration()








'''simple docstring'''



import sys

UpperCamelCase__      :		int       							=  (
    "73167176531330624919225119674426574742355349194934"
    "96983520312774506326239578318016984801869478851843"
    "85861560789112949495459501737958331952853208805511"
    "12540698747158523863050715693290963295227443043557"
    "66896648950445244523161731856403098711121722383113"
    "62229893423380308135336276614282806444486645238749"
    "30358907296290491560440772390713810515859307960866"
    "70172427121883998797908792274921901699720888093776"
    "65727333001053367881220235421809751254540594752243"
    "52584907711670556013604839586446706324415722155397"
    "53697817977846174064955149290862569321978468622482"
    "83972241375657056057490261407972968652414535100474"
    "82166370484403199890008895243450658541227588666881"
    "16427171479924442928230863465674813919123162824586"
    "17866458359124566529476545682848912883142607690042"
    "24219022671055626321111109370544217506941658960408"
    "07198403850962455444362981230987879927244284909188"
    "84580156166097919133875499200524063689912560717606"
    "05886116467109405077541002256983155200055935729725"
    "71636269561882670428252483600823257530420752963450"
)
def    lowerCAmelCase_	(				SCREAMING_SNAKE_CASE_ = N						)     ->     int:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE      =				-sys.maxsize - 1
   for i in range(len(SCREAMING_SNAKE_CASE_						) - 12						):
      _SCREAMING_SNAKE_CASE      =				1
      for j in range(13						):
         product *= int(n[i + j]						)
      if product > largest_product:
         _SCREAMING_SNAKE_CASE      =				product
   return largest_product


if __name__ == "__main__":
     print(f"""{solution() = }""")






