

import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute







def       A_				(   _UpperCAmelCase = 3   ):
						if isinstance(_UpperCAmelCase    ,     _UpperCAmelCase   ):
												raise TypeError("number of qubits must be a integer."   )
						if number_of_qubits <= 0:
												raise ValueError("number of qubits must be > 0."   )
						if math.floor(_UpperCAmelCase   ) != number_of_qubits:
												raise ValueError("number of qubits must be exact integer."   )
						if number_of_qubits > 10:
												raise ValueError("number of qubits too large to simulate(>10)."   )

						SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	QuantumRegister(_UpperCAmelCase    ,     "qr"   )
						SCREAMING_SNAKE_CASE_:			int  		=	ClassicalRegister(_UpperCAmelCase    ,     "cr"   )

						SCREAMING_SNAKE_CASE_:			Optional[int]  		=	QuantumCircuit(_UpperCAmelCase    ,     _UpperCAmelCase   )

						SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	number_of_qubits

						for i in range(_UpperCAmelCase   ):
												quantum_circuit.h(number_of_qubits - i - 1   )
												counter -= 1
												for j in range(_UpperCAmelCase   ):
																		quantum_circuit.cp(np.pi / 2 ** (counter - j)    ,     _UpperCAmelCase    ,     _UpperCAmelCase   )

						for k in range(number_of_qubits // 2   ):
												quantum_circuit.swap(_UpperCAmelCase    ,     number_of_qubits - k - 1   )

						# measure all the qubits
						quantum_circuit.measure(_UpperCAmelCase    ,     _UpperCAmelCase   )
						# simulate with 10000 shots
						SCREAMING_SNAKE_CASE_:			Optional[int]  		=	Aer.get_backend("qasm_simulator"   )
						SCREAMING_SNAKE_CASE_:			int  		=	execute(_UpperCAmelCase    ,     _UpperCAmelCase    ,     shots=1_00_00   )

						return job.result().get_counts(_UpperCAmelCase   )


if __name__ == "__main__":
						print(
						    f'''Total count for quantum fourier transform state is: \
    {quantum_fourier_transform(3)}'''
						)









import doctest
from collections import deque

import numpy as np



class   __lowercase    :




			"""simple docstring"""







			def __init__(			self  :					Union[str, Any]):
									SCREAMING_SNAKE_CASE_:			int  		=	[2, 1, 2, -1]
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	[1, 2, 3, 4]




			def 	_SCREAMING_SNAKE_CASE      (			self  :					Tuple):
									SCREAMING_SNAKE_CASE_:			Any  		=	len(self.first_signal)
									SCREAMING_SNAKE_CASE_:			Dict  		=	len(self.second_signal)

									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	max(lowerCAmelCase__       ,						lowerCAmelCase__)

									# create a zero matrix of max_length x max_length
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	[[0] * max_length for i in range(lowerCAmelCase__)]

									# fills the smaller signal with zeros to make both signals of same length
									if length_first_signal < length_second_signal:
															self.first_signal += [0] * (max_length - length_first_signal)
									elif length_first_signal > length_second_signal:
															self.second_signal += [0] * (max_length - length_second_signal)
									for i in range(lowerCAmelCase__):
															SCREAMING_SNAKE_CASE_:			Tuple  		=	deque(self.second_signal)
															rotated_signal.rotate(lowerCAmelCase__)
															for j, item in enumerate(lowerCAmelCase__):
																					matrix[i][j] += item

        # multiply the matrix with the first signal
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	np.matmul(np.transpose(lowerCAmelCase__)       ,						np.transpose(self.first_signal))

									# rounding-off to two decimal places
									return [round(lowerCAmelCase__       ,						2) for i in final_signal]


if __name__ == "__main__":
						doctest.testmod()






