

from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

UpperCAmelCase__ :     Optional[int]				    =    TypeVar("""T""")







class        a__       (   Generic[T]       ):







  """simple docstring"""




  UpperCAmelCase__      : deque[T]  # Cache store of keys
  UpperCAmelCase__      : set[T]  # References of the keys in cache
  UpperCAmelCase__      : int			       =1_0  # Maximum capacity of cache


  def __init__(			self    : List[str]				,				UpperCAmelCase__    : int		)					->None:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[int]       =   deque()
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   set()
        if not n:
              SCREAMING_SNAKE_CASE :      Optional[int]       =   sys.maxsize
        elif n < 0:
              raise ValueError("""n should be an integer greater than 0."""		)
        else:
              SCREAMING_SNAKE_CASE :      Optional[Any]       =   n


  def  _lowercase      (			self    : Optional[int]				,				UpperCAmelCase__    : T		)					->None:
        """simple docstring"""







        if x not in self.key_reference:
              if len(self.dq_store		) == LRUCache._MAX_CAPACITY:
                    SCREAMING_SNAKE_CASE :      Optional[int]       =   self.dq_store.pop()
                    self.key_reference.remove(UpperCAmelCase__		)
        else:
              self.dq_store.remove(UpperCAmelCase__		)

        self.dq_store.appendleft(UpperCAmelCase__		)
        self.key_reference.add(UpperCAmelCase__		)


  def  _lowercase      (			self    : str		)					->None:
        """simple docstring"""







        for k in self.dq_store:
              print(UpperCAmelCase__		)




  def __repr__(			self    : int		)					->str:
        """simple docstring"""







        return f"LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store		)}"


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  UpperCAmelCase__ :     LRUCache[str | int]				    =    LRUCache(4)
  lru_cache.refer("""A""")
  lru_cache.refer(2)
  lru_cache.refer(3)
  lru_cache.refer("""A""")
  lru_cache.refer(4)
  lru_cache.refer(5)
  lru_cache.display()

  print(lru_cache)
  assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"







from typing import Any

import numpy as np






def 					__lowercase      (     _A			)     ->						bool:
      return np.array_equal(_A						,    matrix.conjugate().T			)






def 					__lowercase      (     _A						,    _A			)     ->						Any:
      SCREAMING_SNAKE_CASE :      Optional[int]       =   v.conjugate().T
      SCREAMING_SNAKE_CASE :      List[Any]       =   v_star.dot(_A			)
      assert isinstance(_A						,    np.ndarray			)
      return (v_star_dot.dot(_A			)) / (v_star.dot(_A			))






def 					__lowercase      (     )     ->						None:
      SCREAMING_SNAKE_CASE :      Any       =   np.array([[2, 2 + 1J, 4], [2 - 1J, 3, 1J], [4, -1J, 1]]			)
      SCREAMING_SNAKE_CASE :      Optional[int]       =   np.array([[1], [2], [3]]			)
      assert is_hermitian(_A			), F"{a} is not hermitian."
      print(rayleigh_quotient(_A						,    _A			)			)

      SCREAMING_SNAKE_CASE :      Any       =   np.array([[1, 2, 4], [2, 3, -1], [4, -1, 1]]			)
      assert is_hermitian(_A			), F"{a} is not hermitian."
      assert rayleigh_quotient(_A						,    _A			) == float(3			)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  tests()




