





from __future__ import annotations

import numpy as np
from numpy import floataa
from numpy.typing import NDArray







def    A				(							UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  ):
					_snake_case       , _snake_case       :					List[Any]				       =   coefficient_matrix.shape
					_snake_case       , _snake_case       :					Any				       =   constant_matrix.shape

					if rowsa != colsa:
										_snake_case       :					Any				       =   F"""Coefficient matrix dimensions must be nxn but received {rowsa}x{colsa}"""
										raise ValueError(UpperCAmelCase				)

					if colsa != 1:
										_snake_case       :					List[Any]				       =   F"""Constant matrix must be nx1 but received {rowsa}x{colsa}"""
										raise ValueError(UpperCAmelCase				)

					if rowsa != rowsa:
										_snake_case       :					Union[str, Any]				       =   (
										    "Coefficient and constant matrices dimensions must be nxn and nx1 but "
										    F"""received {rowsa}x{colsa} and {rowsa}x{colsa}"""
										)
										raise ValueError(UpperCAmelCase				)

					if len(UpperCAmelCase				) != rowsa:
										_snake_case       :					Any				       =   (
										    "Number of initial values must be equal to number of rows in coefficient "
										    F"""matrix but received {len(UpperCAmelCase				)} and {rowsa}"""
										)
										raise ValueError(UpperCAmelCase				)

					if iterations <= 0:
										raise ValueError("Iterations must be at least 1"				)

					_snake_case       :					NDArray[floataa]				       =   np.concatenate(
					    (coefficient_matrix, constant_matrix)  ,  axis=1				)

					_snake_case       , _snake_case       :					Dict				       =   table.shape

					strictly_diagonally_dominant(UpperCAmelCase				)

					# Iterates the whole matrix for given number of times
					for _ in range(UpperCAmelCase				):
										_snake_case       :					Any				       =   []
										for row in range(UpperCAmelCase				):
															_snake_case       :					Optional[Any]				       =   0
															for col in range(UpperCAmelCase				):
																				if col == row:
																									_snake_case       :					str				       =   table[row][col]
																				elif col == cols - 1:
																									_snake_case       :					Union[str, Any]				       =   table[row][col]
																				else:
																									temp += (-1) * table[row][col] * init_val[col]
															_snake_case       :					Dict				       =   (temp + val) / denom
															new_val.append(UpperCAmelCase				)
										_snake_case       :					int				       =   new_val

					return [float(UpperCAmelCase				) for i in new_val]







def    A				(							UpperCAmelCase				):
					_snake_case       , _snake_case       :					Any				       =   table.shape

					_snake_case       :					List[Any]				       =   True

					for i in range(0  ,  UpperCAmelCase				):
										_snake_case       :					Dict				       =   0
										for j in range(0  ,  cols - 1				):
															if i == j:
																				continue
															else:
																				total += table[i][j]

										if table[i][i] <= total:
															raise ValueError("Coefficient matrix is not strictly diagonally dominant"				)

					return is_diagonally_dominant


# Test Cases
if __name__ == "__main__":
							import doctest

							doctest.testmod()






from __future__ import annotations

import typing
from collections.abc import Iterable

import numpy as np

__lowerCAmelCase :Union[str, Any]     =    typing.Union[Iterable[float], Iterable[int], np.ndarray]  # noqa: UP007
__lowerCAmelCase :Optional[Any]     =    typing.Union[np.floataa, int, float]  # noqa: UP007







def    A				(							UpperCAmelCase  ,  UpperCAmelCase				):
					return np.sqrt(np.sum((np.asarray(UpperCAmelCase				) - np.asarray(UpperCAmelCase				)) ** 2				)				)







def    A				(							UpperCAmelCase  ,  UpperCAmelCase				):
					return sum((va - va) ** 2 for va, va in zip(UpperCAmelCase  ,  UpperCAmelCase				)				) ** (1 / 2)


if __name__ == "__main__":







							def    A				(							):
												from timeit import timeit

												print("Without Numpy"				)
												print(
												    timeit(
												        "euclidean_distance_no_np([1, 2, 3], [4, 5, 6])"  ,  number=10_000  ,  globals=globals()  ,  )				)
												print("With Numpy"				)
												print(
												    timeit(
												        "euclidean_distance([1, 2, 3], [4, 5, 6])"  ,  number=10_000  ,  globals=globals()  ,  )				)

							benchmark()