

import unittest

import numpy as np







def 							_lowerCamelCase   (			SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE = None		,				):
      '''simple docstring'''







      A_							       =		np.shape(SCREAMING_SNAKE_CASE   )
      A_							       =		np.shape(SCREAMING_SNAKE_CASE   )
      A_							       =		np.shape(SCREAMING_SNAKE_CASE   )

      if shape_a[0] != shape_b[0]:
            A_							       =		(
                '''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(SCREAMING_SNAKE_CASE   )

      if shape_b[1] != shape_c[1]:
            A_							       =		(
                '''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(SCREAMING_SNAKE_CASE   )

      A_							       =		pseudo_inv
      if a_inv is None:
            try:
                  A_							       =		np.linalg.inv(SCREAMING_SNAKE_CASE   )
            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    _lowercase				(					unittest.TestCase			):

   def     UpperCamelCase					(				self	:    List[Any]       ) ->			None:
         """simple docstring"""





         A_							       =		np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]       )
         A_							       =		np.array([[0, 3], [3, 0], [2, 3]]       )
         A_							       =		np.array([[2, 1], [6, 3]]       )

         A_							       =		schur_complement(lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__       )

         A_							       =		np.block([[a, b], [b.T, c]]       )

         A_							       =		np.linalg.det(lowerCamelCase__       )
         A_							       =		np.linalg.det(lowerCamelCase__       )
         A_							       =		np.linalg.det(lowerCamelCase__       )

         self.assertAlmostEqual(lowerCamelCase__			,						det_a * det_s       )

   def     UpperCamelCase					(				self	:    Union[str, Any]       ) ->			None:
         """simple docstring"""





         A_							       =		np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]       )
         A_							       =		np.array([[0, 3], [3, 0], [2, 3]]       )
         A_							       =		np.array([[2, 1], [6, 3]]       )

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





   def     UpperCamelCase					(				self	:    Optional[int]       ) ->			None:
         """simple docstring"""





         A_							       =		np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]       )
         A_							       =		np.array([[0, 3], [3, 0], [2, 3]]       )
         A_							       =		np.array([[2, 1, 3], [6, 3, 5]]       )

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


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      unittest.main()








def 							_lowerCamelCase   (			SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE   ):
      '''simple docstring'''







      return int((input_a, input_a).count(0   ) != 0   )







def 							_lowerCamelCase   (			):
      '''simple docstring'''







      assert nand_gate(0		,				0   ) == 1
      assert nand_gate(0		,				1   ) == 1
      assert nand_gate(1		,				0   ) == 1
      assert nand_gate(1		,				1   ) == 0


if __name__ == "__main__":
      print(nand_gate(0, 0))
      print(nand_gate(0, 1))
      print(nand_gate(1, 0))
      print(nand_gate(1, 1))





