




def 	_a      (						SCREAMING_SNAKE_CASE_							:				Tuple      ,      SCREAMING_SNAKE_CASE_							:				Any     ):
					return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2







def 	_a      (						SCREAMING_SNAKE_CASE_							:				Dict      ,      SCREAMING_SNAKE_CASE_							:				Union[str, Any]=0     ):
					return sorted(SCREAMING_SNAKE_CASE_      ,      key=lambda SCREAMING_SNAKE_CASE_     : x[column]     )







def 	_a      (						SCREAMING_SNAKE_CASE_							:				int      ,      SCREAMING_SNAKE_CASE_							:				Union[str, Any]      ,      SCREAMING_SNAKE_CASE_							:				List[Any]=float("inf"     )     ):

					for i in range(points_counts - 1     ):
										for j in range(i + 1      ,      SCREAMING_SNAKE_CASE_     ):
															__lowerCAmelCase				   =       euclidean_distance_sqr(points[i]      ,      points[j]     )
															if current_dis < min_dis:
																				__lowerCAmelCase				   =       current_dis
					return min_dis







def 	_a      (						SCREAMING_SNAKE_CASE_							:				Optional[int]      ,      SCREAMING_SNAKE_CASE_							:				Optional[int]      ,      SCREAMING_SNAKE_CASE_							:				Optional[Any]=float("inf"     )     ):

					for i in range(min(6      ,      points_counts - 1     )      ,      SCREAMING_SNAKE_CASE_     ):
										for j in range(max(0      ,      i - 6     )      ,      SCREAMING_SNAKE_CASE_     ):
															__lowerCAmelCase				   =       euclidean_distance_sqr(points[i]      ,      points[j]     )
															if current_dis < min_dis:
																				__lowerCAmelCase				   =       current_dis
					return min_dis







def 	_a      (						SCREAMING_SNAKE_CASE_							:				Optional[Any]      ,      SCREAMING_SNAKE_CASE_							:				str      ,      SCREAMING_SNAKE_CASE_							:				Union[str, Any]     ):

					# base case
					if points_counts <= 3:
										return dis_between_closest_pair(SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_     )

					# recursion
					__lowerCAmelCase				   =       points_counts // 2
					__lowerCAmelCase				   =       closest_pair_of_points_sqr(
					    SCREAMING_SNAKE_CASE_      ,      points_sorted_on_y[:mid]      ,      SCREAMING_SNAKE_CASE_     )
					__lowerCAmelCase				   =       closest_pair_of_points_sqr(
					    SCREAMING_SNAKE_CASE_      ,      points_sorted_on_y[mid:]      ,      points_counts - mid     )
					__lowerCAmelCase				   =       min(SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_     )
					__lowerCAmelCase				   =       []
					for point in points_sorted_on_x:
										if abs(point[0] - points_sorted_on_x[mid][0]     ) < closest_pair_dis:
															cross_strip.append(SCREAMING_SNAKE_CASE_     )

					__lowerCAmelCase				   =       dis_between_closest_in_strip(
					    SCREAMING_SNAKE_CASE_      ,      len(SCREAMING_SNAKE_CASE_     )      ,      SCREAMING_SNAKE_CASE_     )
					return min(SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_     )







def 	_a      (						SCREAMING_SNAKE_CASE_							:				List[str]      ,      SCREAMING_SNAKE_CASE_							:				int     ):
					__lowerCAmelCase				   =       column_based_sort(SCREAMING_SNAKE_CASE_      ,      column=0     )
					__lowerCAmelCase				   =       column_based_sort(SCREAMING_SNAKE_CASE_      ,      column=1     )
					return (
					    closest_pair_of_points_sqr(
					        SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_     )
					) ** 0.5


if __name__ == "__main__":
					UpperCamelCase__    			=			[(2, 3), (12, 30), (40, 50), (5, 1), (12, 10), (3, 4)]
					print("""Distance:""", closest_pair_of_points(points, len(points)))












"""simple docstring"""




import unittest

import numpy as np

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__ = None     ,   ):



  '''simple docstring'''
  _a  :       List[Any]             =	np.shape(UpperCamelCase__				)
  _a  :       Any             =	np.shape(UpperCamelCase__				)
  _a  :       Union[str, Any]             =	np.shape(UpperCamelCase__				)

  if shape_a[0] != shape_b[0]:
    _a  :       int             =	(
        """Expected the same number of rows for A and B. """
        F"""Instead found A of size {shape_a} and B of size {shape_b}"""
    )
    raise ValueError(UpperCamelCase__				)

  if shape_b[1] != shape_c[1]:
    _a  :       Tuple             =	(
        """Expected the same number of columns for B and C. """
        F"""Instead found B of size {shape_b} and C of size {shape_c}"""
    )
    raise ValueError(UpperCamelCase__				)

  _a  :       int             =	pseudo_inv
  if a_inv is None:
    try:
      _a  :       Optional[int]             =	np.linalg.inv(UpperCamelCase__				)
    except np.linalg.LinAlgError:
      raise ValueError(
          """Input matrix A is not invertible. Cannot compute Schur complement."""				)

  return mat_c - mat_b.T @ a_inv @ mat_b






class        UpperCamelCase			(	unittest.TestCase      ):


 def _lowercase	(     self		:						int							)					->       None:
   _a  :       str             =	np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]							)
   _a  :       Tuple             =	np.array([[0, 3], [3, 0], [2, 3]]							)
   _a  :       Optional[int]             =	np.array([[2, 1], [6, 3]]							)

   _a  :       Optional[Any]             =	schur_complement(UpperCAmelCase__							,						UpperCAmelCase__							,						UpperCAmelCase__							)

   _a  :       Union[str, Any]             =	np.block([[a, b], [b.T, c]]							)

   _a  :       int             =	np.linalg.det(UpperCAmelCase__							)
   _a  :       Union[str, Any]             =	np.linalg.det(UpperCAmelCase__							)
   _a  :       List[Any]             =	np.linalg.det(UpperCAmelCase__							)

   self.assertAlmostEqual(UpperCAmelCase__							,						det_a * det_s							)


 def _lowercase	(     self		:						int							)					->       None:
   _a  :       Optional[int]             =	np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]							)
   _a  :       Optional[int]             =	np.array([[0, 3], [3, 0], [2, 3]]							)
   _a  :       Union[str, Any]             =	np.array([[2, 1], [6, 3]]							)

   with self.assertRaises(UpperCAmelCase__							):
     schur_complement(UpperCAmelCase__							,						UpperCAmelCase__							,						UpperCAmelCase__							)







 def _lowercase	(     self		:						List[Any]							)					->       None:
   _a  :       Any             =	np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]							)
   _a  :       Dict             =	np.array([[0, 3], [3, 0], [2, 3]]							)
   _a  :       List[Any]             =	np.array([[2, 1, 3], [6, 3, 5]]							)

   with self.assertRaises(UpperCAmelCase__							):
     schur_complement(UpperCAmelCase__							,						UpperCAmelCase__							,						UpperCAmelCase__							)


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 unittest.main()

