



import unittest

from .lib import (
    Matrix,
    Vector,
    axpy,
    square_zero_matrix,
    unit_basis_vector,
    zero_vector,
)

class       _SCREAMING_SNAKE_CASE	(unittest.TestCase ):





     def 	__snake_case    (       self :							List[Any]				)->None:
      __SCREAMING_SNAKE_CASE       :    int       =	Vector([1, 2, 3]				)
      self.assertEqual(x.component(0				)     ,  1				)
      self.assertEqual(x.component(2				)     ,  3				)
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	Vector()





     def 	__snake_case    (       self :							int				)->None:
      __SCREAMING_SNAKE_CASE       :    Any       =	Vector([0, 0, 0, 0, 0, 1]				)
      self.assertEqual(str(UpperCamelCase				)     ,  "(0,0,0,0,0,1)"				)





     def 	__snake_case    (       self :							List[Any]				)->None:
      __SCREAMING_SNAKE_CASE       :    int       =	Vector([1, 2, 3, 4]				)
      self.assertEqual(len(UpperCamelCase				)     ,  4				)





     def 	__snake_case    (       self :							str				)->None:
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	Vector([1, 2]				)
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	Vector([1, 2, 3, 4, 5]				)
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	Vector([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]				)
      __SCREAMING_SNAKE_CASE       :    str       =	Vector([1, -1, 1, -1, 2, -3, 4, -5]				)
      self.assertAlmostEqual(x.euclidean_length()     ,  2.2_3_6     ,  3				)
      self.assertAlmostEqual(y.euclidean_length()     ,  7.4_1_6     ,  3				)
      self.assertEqual(z.euclidean_length()     ,  0				)
      self.assertAlmostEqual(w.euclidean_length()     ,  7.6_1_6     ,  3				)





     def 	__snake_case    (       self :							Dict				)->None:
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	Vector([1, 2, 3]				)
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	Vector([1, 1, 1]				)
      self.assertEqual((x + y).component(0				)     ,  2				)
      self.assertEqual((x + y).component(1				)     ,  3				)
      self.assertEqual((x + y).component(2				)     ,  4				)





     def 	__snake_case    (       self :							Union[str, Any]				)->None:
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	Vector([1, 2, 3]				)
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	Vector([1, 1, 1]				)
      self.assertEqual((x - y).component(0				)     ,  0				)
      self.assertEqual((x - y).component(1				)     ,  1				)
      self.assertEqual((x - y).component(2				)     ,  2				)





     def 	__snake_case    (       self :							Union[str, Any]				)->None:
      __SCREAMING_SNAKE_CASE       :    Any       =	Vector([1, 2, 3]				)
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	Vector([2, -1, 4]				)  # for test of dot product
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	Vector([1, -2, -1]				)
      self.assertEqual(str(x * 3.0				)     ,  "(3.0,6.0,9.0)"				)
      self.assertEqual((a * b)     ,  0				)





     def 	__snake_case    (       self :							int				)->None:
      self.assertEqual(str(zero_vector(1_0				)				).count("0"				)     ,  1_0				)





     def 	__snake_case    (       self :							Optional[int]				)->None:
      self.assertEqual(str(unit_basis_vector(3     ,  1				)				)     ,  "(0,1,0)"				)





     def 	__snake_case    (       self :							int				)->None:
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	Vector([1, 2, 3]				)
      __SCREAMING_SNAKE_CASE       :    str       =	Vector([1, 0, 1]				)
      self.assertEqual(str(axpy(2     ,  UpperCamelCase     ,  UpperCamelCase				)				)     ,  "(3,4,7)"				)





     def 	__snake_case    (       self :							Any				)->None:
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	Vector([1, 0, 0, 0, 0, 0]				)
      __SCREAMING_SNAKE_CASE       :    Tuple       =	x.copy()
      self.assertEqual(str(UpperCamelCase				)     ,  str(UpperCamelCase				)				)





     def 	__snake_case    (       self :							List[str]				)->None:
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	Vector([1, 0, 0]				)
      x.change_component(0     ,  0				)
      x.change_component(1     ,  1				)
      self.assertEqual(str(UpperCamelCase				)     ,  "(0,1,0)"				)





     def 	__snake_case    (       self :							int				)->None:
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      self.assertEqual("|1,2,3|\n|2,4,5|\n|6,7,8|\n"     ,  str(UpperCamelCase				)				)





     def 	__snake_case    (       self :							Optional[int]				)->None:
      __SCREAMING_SNAKE_CASE       :    str       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	[[-3, -1_4, -1_0], [-5, -1_0, -5], [-2, -1, 0]]
      for x in range(a.height()				):
       for y in range(a.width()				):
        self.assertEqual(minors[x][y]     ,  a.minor(UpperCamelCase     ,  UpperCamelCase				)				)





     def 	__snake_case    (       self :							Any				)->None:
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      __SCREAMING_SNAKE_CASE       :    int       =	[[-3, 1_4, -1_0], [5, -1_0, 5], [-2, 1, 0]]
      for x in range(a.height()				):
       for y in range(a.width()				):
        self.assertEqual(cofactors[x][y]     ,  a.cofactor(UpperCamelCase     ,  UpperCamelCase				)				)





     def 	__snake_case    (       self :							Optional[Any]				)->None:
      __SCREAMING_SNAKE_CASE       :    List[str]       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      self.assertEqual(-5     ,  a.determinant()				)





     def 	__snake_case    (       self :							Optional[Any]				)->None:
      __SCREAMING_SNAKE_CASE       :    Dict       =	Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]     ,  3     ,  3				)
      __SCREAMING_SNAKE_CASE       :    str       =	Vector([1, 2, 3]				)
      self.assertEqual("(14,32,50)"     ,  str(a * x				)				)
      self.assertEqual("|2,4,6|\n|8,10,12|\n|14,16,18|\n"     ,  str(a * 2				)				)





     def 	__snake_case    (       self :							List[str]				)->None:
      __SCREAMING_SNAKE_CASE       :    str       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      a.change_component(0     ,  2     ,  5				)
      self.assertEqual("|1,2,5|\n|2,4,5|\n|6,7,8|\n"     ,  str(UpperCamelCase				)				)





     def 	__snake_case    (       self :							int				)->None:
      __SCREAMING_SNAKE_CASE       :    int       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      self.assertEqual(7     ,  a.component(2     ,  1				)     ,  0.0_1				)





     def 	__snake_case    (       self :							Optional[int]				)->None:
      __SCREAMING_SNAKE_CASE       :    Any       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      __SCREAMING_SNAKE_CASE       :    Tuple       =	Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 1_0]]     ,  3     ,  3				)
      self.assertEqual("|2,4,10|\n|4,8,10|\n|12,14,18|\n"     ,  str(a + b				)				)





     def 	__snake_case    (       self :							Any				)->None:
      __SCREAMING_SNAKE_CASE       :    Tuple       =	Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]     ,  3     ,  3				)
      __SCREAMING_SNAKE_CASE       :    Dict       =	Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 1_0]]     ,  3     ,  3				)
      self.assertEqual("|0,0,-4|\n|0,0,0|\n|0,0,-2|\n"     ,  str(a - b				)				)






     def 	__snake_case    (       self :							str				)->None:
      self.assertEqual(
          "|0,0,0,0,0|\n|0,0,0,0,0|\n|0,0,0,0,0|\n|0,0,0,0,0|\n|0,0,0,0,0|\n"     ,  str(square_zero_matrix(5				)				)     ,  )


if __name__ == "__main__":
      unittest.main()











from collections.abc import Generator
from math import sin






def 	_lowerCAmelCase						(				__lowerCamelCase   :     bytes     ):



 """simple docstring"""





 if len(__lowerCamelCase     ) != 32:
  raise ValueError("Input must be of length 32"     )

 __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	b""
 for i in [3, 2, 1, 0]:
  little_endian += string_aa[8 * i : 8 * i + 8]
 return little_endian






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int     ):



 """simple docstring"""





 if i < 0:
  raise ValueError("Input must be non-negative"     )

 __SCREAMING_SNAKE_CASE       :    Any       =	format(__lowerCamelCase		,	"08x"     )[-8:]
 __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	b""
 for i in [3, 2, 1, 0]:
  little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode("utf-8"     )
 return little_endian_hex






def 	_lowerCAmelCase						(				__lowerCamelCase   :     bytes     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    Any       =	b""
 for char in message:
  bit_string += format(__lowerCamelCase		,	"08b"     ).encode("utf-8"     )
 __SCREAMING_SNAKE_CASE       :    List[str]       =	format(len(__lowerCamelCase     )		,	"064b"     ).encode("utf-8"     )

 # Pad bit_string to a multiple of 512 chars
 bit_string += b"1"
 while len(__lowerCamelCase     ) % 512 != 448:
  bit_string += b"0"
 bit_string += to_little_endian(start_len[32:]     ) + to_little_endian(start_len[:32]     )

 return bit_string






def 	_lowerCAmelCase						(				__lowerCamelCase   :     bytes     ):



 """simple docstring"""





 if len(__lowerCamelCase     ) % 512 != 0:
  raise ValueError("Input must have length that's a multiple of 512"     )

 for pos in range(0		,	len(__lowerCamelCase     )		,	512     ):
  __SCREAMING_SNAKE_CASE       :    int       =	bit_string[pos : pos + 512]
  __SCREAMING_SNAKE_CASE       :    Tuple       =	[]
  for i in range(0		,	512		,	32     ):
   block_words.append(int(to_little_endian(block[i : i + 32]     )		,	2     )     )
  yield block_words






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int     ):



 """simple docstring"""





 if i < 0:
  raise ValueError("Input must be non-negative"     )

 __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	format(__lowerCamelCase		,	"032b"     )
 __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	""
 for c in i_str:
  new_str += "1" if c == "0" else "0"
 return int(__lowerCamelCase		,	2     )






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int		,	__lowerCamelCase   :     int     ):



 """simple docstring"""





 return (a + b) % 2**32






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int		,	__lowerCamelCase   :     int     ):



 """simple docstring"""





 if i < 0:
  raise ValueError("Input must be non-negative"     )
 if shift < 0:
  raise ValueError("Shift must be non-negative"     )
 return ((i << shift) ^ (i >> (32 - shift))) % 2**32






def 	_lowerCAmelCase						(				__lowerCamelCase   :     bytes     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    Tuple       =	preprocess(__lowerCamelCase     )

 __SCREAMING_SNAKE_CASE       :    List[Any]       =	[int(2**32 * abs(sin(i + 1     )     )     ) for i in range(64     )]

 # Starting states
 __SCREAMING_SNAKE_CASE       :    Tuple       =	0X67452301
 __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	0Xefcdab89
 __SCREAMING_SNAKE_CASE       :    Optional[int]       =	0X98badcfe
 __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	0X10325476

 __SCREAMING_SNAKE_CASE       :    List[Any]       =	[
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
 ]

 # Process bit string in chunks, each with 16 32-char words
 for block_words in get_block_words(__lowerCamelCase     ):
  __SCREAMING_SNAKE_CASE       :    Any       =	aa
  __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	ba
  __SCREAMING_SNAKE_CASE       :    str       =	ca
  __SCREAMING_SNAKE_CASE       :    Dict       =	da

  # Hash current chunk
  for i in range(64     ):
   if i <= 15:
    # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
    __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	d ^ (b & (c ^ d))
    __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	i
   elif i <= 31:
    # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
    __SCREAMING_SNAKE_CASE       :    int       =	c ^ (d & (b ^ c))
    __SCREAMING_SNAKE_CASE       :    int       =	(5 * i + 1) % 16
   elif i <= 47:
    __SCREAMING_SNAKE_CASE       :    List[str]       =	b ^ c ^ d
    __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	(3 * i + 5) % 16
   else:
    __SCREAMING_SNAKE_CASE       :    Any       =	c ^ (b | not_aa(__lowerCamelCase     ))
    __SCREAMING_SNAKE_CASE       :    str       =	(7 * i) % 16
   __SCREAMING_SNAKE_CASE       :    List[str]       =	(f + a + added_consts[i] + block_words[g]) % 2**32
   __SCREAMING_SNAKE_CASE       :    Dict       =	d
   __SCREAMING_SNAKE_CASE       :    str       =	c
   __SCREAMING_SNAKE_CASE       :    Tuple       =	b
   __SCREAMING_SNAKE_CASE       :    Optional[int]       =	sum_aa(__lowerCamelCase		,	left_rotate_aa(__lowerCamelCase		,	shift_amounts[i]     )     )

  # Add hashed chunk to running total
  __SCREAMING_SNAKE_CASE       :    Dict       =	sum_aa(__lowerCamelCase		,	__lowerCamelCase     )
  __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	sum_aa(__lowerCamelCase		,	__lowerCamelCase     )
  __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	sum_aa(__lowerCamelCase		,	__lowerCamelCase     )
  __SCREAMING_SNAKE_CASE       :    str       =	sum_aa(__lowerCamelCase		,	__lowerCamelCase     )

 __SCREAMING_SNAKE_CASE       :    List[str]       =	reformat_hex(__lowerCamelCase     ) + reformat_hex(__lowerCamelCase     ) + reformat_hex(__lowerCamelCase     ) + reformat_hex(__lowerCamelCase     )
 return digest


if __name__ == "__main__":
      import doctest

      doctest.testmod()






