






'''simple docstring'''
import qiskit





def  _a(  UpperCamelCase__				:						int,	UpperCamelCase__				:						int							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				str									=qiskit.Aer.get_backend('''aer_simulator'''							)

      SCREAMING_SNAKE_CASE__     :				List[Any]									=qiskit.QuantumCircuit(4,	2							)
      # encode inputs in qubits 0 and 1
      if bita == 1:
            qc_ha.x(0							)
      if bita == 1:
            qc_ha.x(1							)
      qc_ha.barrier()

      # use cnots to write XOR of the inputs on qubit2
      qc_ha.cx(0,	2							)
      qc_ha.cx(1,	2							)

      # use ccx / toffoli gate to write AND of the inputs on qubit3
      qc_ha.ccx(0,	1,	3							)
      qc_ha.barrier()

      # extract outputs
      qc_ha.measure(2,	0							)  # extract XOR value
      qc_ha.measure(3,	1							)  # extract AND value

      # Execute the circuit on the qasm simulator
      SCREAMING_SNAKE_CASE__     :				List[str]									=qiskit.execute(UpperCamelCase__,	UpperCamelCase__,	shots=1_0_0_0							)

      # Return the histogram data of the results of the experiment
      return job.result().get_counts(UpperCamelCase__							)


if __name__ == "__main__":
  a_					= half_adder(1, 1)
  print(F'''Half Adder Output Qubit Counts: {counts}''')







'''simple docstring'''
from __future__ import annotations

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





def  _a(  UpperCamelCase__				:						NDArray[floataa],	UpperCamelCase__				:						NDArray[floataa],	UpperCamelCase__				:						list[int],	UpperCamelCase__				:						int,	):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__		,	SCREAMING_SNAKE_CASE__     :				Tuple									=coefficient_matrix.shape
      SCREAMING_SNAKE_CASE__		,	SCREAMING_SNAKE_CASE__     :				Tuple									=constant_matrix.shape

      if rowsa != colsa:
            SCREAMING_SNAKE_CASE__     :				Any									=f"Coefficient matrix dimensions must be nxn but received {rowsa}x{colsa}"
            raise ValueError(UpperCamelCase__							)

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

      if rowsa != rowsa:
            SCREAMING_SNAKE_CASE__     :				str									=(
                '''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:
            SCREAMING_SNAKE_CASE__     :				Union[str, 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'''							)

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

      SCREAMING_SNAKE_CASE__		,	SCREAMING_SNAKE_CASE__     :				Any									=table.shape

      strictly_diagonally_dominant(UpperCamelCase__							)

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

      return [float(UpperCamelCase__							) for i in new_val]





def  _a(  UpperCamelCase__				:						NDArray[floataa]							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__		,	SCREAMING_SNAKE_CASE__     :				Optional[int]									=table.shape

      SCREAMING_SNAKE_CASE__     :				Any									=True

      for i in range(0,	UpperCamelCase__							):
            SCREAMING_SNAKE_CASE__     :				int									=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()