
from __future__ import annotations

from typing import Any



def 		UpperCamelCase    (					*_UpperCAmelCase     :      list[list[int]]     )      -> list[list[int]]:






						'''simple docstring'''

						if all(_check_not_integer(_UpperCAmelCase     ) for m in matrix_s     ):
												for i in matrix_s[1:]:
																		_verify_matrix_sizes(matrix_s[0]   , _UpperCAmelCase     )
												return [[sum(_UpperCAmelCase     ) for t in zip(*_UpperCAmelCase     )] for m in zip(*_UpperCAmelCase     )]
						raise TypeError("Expected a matrix, got int/list instead"     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]   , _UpperCAmelCase     :      list[list[int]]     )      -> list[list[int]]:






						'''simple docstring'''

						if (
						    _check_not_integer(_UpperCAmelCase     )
						    and _check_not_integer(_UpperCAmelCase     )
						    and _verify_matrix_sizes(_UpperCAmelCase   , _UpperCAmelCase     )
						):
												return [[i - j for i, j in zip(*_UpperCAmelCase     )] for m in zip(_UpperCAmelCase   , _UpperCAmelCase     )]
						raise TypeError("Expected a matrix, got int/list instead"     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]   , _UpperCAmelCase     :      int | float     )      -> list[list[float]]:






						'''simple docstring'''

						return [[x * n for x in row] for row in matrix]



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]   , _UpperCAmelCase     :      list[list[int]]     )      -> list[list[int]]:






						'''simple docstring'''

						if _check_not_integer(_UpperCAmelCase     ) and _check_not_integer(_UpperCAmelCase     ):
												_lowercase			,						_lowercase					:  Tuple    			=      _verify_matrix_sizes(_UpperCAmelCase   , _UpperCAmelCase     )

						if cols[0] != rows[1]:
												_lowercase					:  Tuple    			=      (
												    "Cannot multiply matrix of dimensions "
												    f"""({rows[0]},{cols[0]}) and ({rows[1]},{cols[1]})"""
												)
												raise ValueError(_UpperCAmelCase     )
						return [
						    [sum(m * n for m, n in zip(_UpperCAmelCase   , _UpperCAmelCase     )     ) for j in zip(*_UpperCAmelCase     )] for i in matrix_a
						]



def 		UpperCamelCase    (					_UpperCAmelCase     :      int     )      -> list[list[int]]:






						'''simple docstring'''

						_lowercase					:  List[str]    			=      int(_UpperCAmelCase     )
						return [[int(row == column     ) for column in range(_UpperCAmelCase     )] for row in range(_UpperCAmelCase     )]



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]   , _UpperCAmelCase     :      bool = True     )      -> list[list[int]] | map[list[int]]:






						'''simple docstring'''

						if _check_not_integer(_UpperCAmelCase     ):
												if return_map:
																		return map(_UpperCAmelCase   , zip(*_UpperCAmelCase     )     )
												else:
																		return list(map(_UpperCAmelCase   , zip(*_UpperCAmelCase     )     )     )
						raise TypeError("Expected a matrix, got int/list instead"     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]   , _UpperCAmelCase     :      int   , _UpperCAmelCase     :      int     )      -> list[list[int]]:






						'''simple docstring'''

						_lowercase					:  Optional[Any]    			=      matrix[:row] + matrix[row + 1 :]
						return [row[:column] + row[column + 1 :] for row in minor]



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]     )      -> Any:






						'''simple docstring'''

						if len(_UpperCAmelCase     ) == 1:
												return matrix[0][0]

						return sum(
						    x * determinant(minor(_UpperCAmelCase   , 0   , _UpperCAmelCase     )     ) * (-1) ** i
						    for i, x in enumerate(matrix[0]     )     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]     )      -> list[list[float]] | None:






						'''simple docstring'''

						_lowercase					:  Optional[Any]    			=      determinant(_UpperCAmelCase     )
						if det == 0:
												return None

						_lowercase					:  Dict    			=      [
						    [determinant(minor(_UpperCAmelCase   , _UpperCAmelCase   , _UpperCAmelCase     )     ) for j in range(len(_UpperCAmelCase     )     )]
						    for i in range(len(_UpperCAmelCase     )     )
						]

						_lowercase					:  Any    			=      [
						    [x * (-1) ** (row + col) for col, x in enumerate(matrix_minor[row]     )]
						    for row in range(len(_UpperCAmelCase     )     )
						]
						_lowercase					:  List[str]    			=      list(transpose(_UpperCAmelCase     )     )
						return scalar_multiply(_UpperCAmelCase   , 1 / det     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]     )      -> bool:






						'''simple docstring'''

						return not isinstance(_UpperCAmelCase   , _UpperCAmelCase     ) and not isinstance(matrix[0]   , _UpperCAmelCase     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]     )      -> tuple[int, int]:






						'''simple docstring'''

						return len(_UpperCAmelCase     ), len(matrix[0]     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[list[int]]   , _UpperCAmelCase     :      list[list[int]]     )      -> tuple[tuple[int, int], tuple[int, int]]:






						'''simple docstring'''

						_lowercase					:  List[str]    			=      _shape(_UpperCAmelCase     ) + _shape(_UpperCAmelCase     )
						if shape[0] != shape[3] or shape[1] != shape[2]:
												_lowercase					:  Optional[int]    			=      (
												    "operands could not be broadcast together with shape "
												    f"""({shape[0], shape[1]}), ({shape[2], shape[3]})"""
												)
												raise ValueError(_UpperCAmelCase     )
						return (shape[0], shape[2]), (shape[1], shape[3])



def 		UpperCamelCase    (					)      -> None:






						'''simple docstring'''

						_lowercase					:  Optional[Any]    			=      [[12, 10], [3, 9]]
						_lowercase					:  Optional[Any]    			=      [[3, 4], [7, 4]]
						_lowercase					:  Optional[int]    			=      [[11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34], [41, 42, 43, 44]]
						_lowercase					:  str    			=      [[3, 0, 2], [2, 0, -2], [0, 1, 1]]
						print(f"""Add Operation, {add(_UpperCAmelCase   , _UpperCAmelCase     ) = } \n"""     )
						print(
						    f"""Multiply Operation, {multiply(_UpperCAmelCase   , _UpperCAmelCase     ) = } \n"""   , )
						print(f"""Identity: {identity(5     )}\n"""     )
						print(f"""Minor of {matrix_c} = {minor(_UpperCAmelCase   , 1   , 2     )} \n"""     )
						print(f"""Determinant of {matrix_b} = {determinant(_UpperCAmelCase     )} \n"""     )
						print(f"""Inverse of {matrix_d} = {inverse(_UpperCAmelCase     )}\n"""     )


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()






from __future__ import annotations



def 		UpperCamelCase    (					_UpperCAmelCase     :      list[int]   , _UpperCAmelCase     :      int     )      -> int:






						'''simple docstring'''

						_lowercase			,						_lowercase					:  Any    			=      0, len(_UpperCAmelCase     ) - 1
						while start_ind <= end_ind:
												if array[start_ind] == search_item:
																		return start_ind
												elif array[end_ind] == search_item:
																		return end_ind
												else:
																		start_ind += 1
																		end_ind -= 1
    # returns -1 if search_item is not found in array
						return -1


if __name__ == "__main__":
							print(double_linear_search(list(range(100)), 40))




