


from __future__ import annotations

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





def   _UpperCAmelCase       (     UpperCAmelCase      :			NDArray[floataa]						,	UpperCAmelCase      :			NDArray[floataa]						,	UpperCAmelCase      :			list[int]						,	UpperCAmelCase      :			int						,	):
      """simple docstring"""




      __lowerCamelCase     :      int       						=						coefficient_matrix.shape
      __lowerCamelCase     :      Dict       						=						constant_matrix.shape

      if rowsa != colsa:
            __lowerCamelCase     :      Optional[int]       						=						f"""Coefficient matrix dimensions must be nxn but received {rowsa}x{colsa}"""
            raise ValueError(UpperCAmelCase      )

      if colsa != 1:
            __lowerCamelCase     :      str       						=						f"""Constant matrix must be nx1 but received {rowsa}x{colsa}"""
            raise ValueError(UpperCAmelCase      )

      if rowsa != rowsa:
            __lowerCamelCase     :      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:
            __lowerCamelCase     :      Optional[int]       						=						(
                """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"""      )

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

      __lowerCamelCase     :      Union[str, Any]       						=						table.shape

      strictly_diagonally_dominant(UpperCAmelCase      )

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

      return [float(UpperCAmelCase      ) for i in new_val]





def   _UpperCAmelCase       (     UpperCAmelCase      :			NDArray[floataa]      ):
      """simple docstring"""




      __lowerCamelCase     :      List[str]       						=						table.shape

      __lowerCamelCase     :      Dict       						=						True

      for i in range(0						,	UpperCAmelCase      ):
            __lowerCamelCase     :      List[str]       						=						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 typing import Any





def   _UpperCAmelCase       (     UpperCAmelCase      :			list      ):
      """simple docstring"""




      if not input_list:
            return []
      __lowerCamelCase     :      int       						=						[input_list.count(UpperCAmelCase      ) for value in input_list]
      __lowerCamelCase     :      Tuple       						=						max(UpperCAmelCase      )  # Gets the maximum count in the input list.
      # Gets values of modes
      return sorted({input_list[i] for i, value in enumerate(UpperCAmelCase      ) if value == y}      )


if __name__ == "__main__":
    import doctest

    doctest.testmod()



