diff --git a/qutes.code-workspace b/qutes.code-workspace index 8b5d79b..089c547 100644 --- a/qutes.code-workspace +++ b/qutes.code-workspace @@ -13,7 +13,9 @@ "visitors": true }, "cSpell.words": [ - "Antlr" + "Antlr", + "Qiskit", + "qustring" ], "pylint.importStrategy": "fromEnvironment", "python.testing.cwd": "./src", diff --git a/src/quantum_circuit/__init__.py b/src/quantum_circuit/__init__.py index 5c151fd..3f822a4 100644 --- a/src/quantum_circuit/__init__.py +++ b/src/quantum_circuit/__init__.py @@ -3,4 +3,5 @@ from quantum_circuit.quantum_circuit import QuantumCircuit from quantum_circuit.quantum_circuit_handler import QuantumCircuitHandler from quantum_circuit.quantum_register import QuantumRegister -from quantum_circuit.qutes_gates import QutesGates \ No newline at end of file +from quantum_circuit.qutes_gates import QutesGates +from quantum_circuit.quantum_register import QiskitQubit \ No newline at end of file diff --git a/src/quantum_circuit/quantum_circuit_handler.py b/src/quantum_circuit/quantum_circuit_handler.py index 08b6ef3..b79ac27 100644 --- a/src/quantum_circuit/quantum_circuit_handler.py +++ b/src/quantum_circuit/quantum_circuit_handler.py @@ -2,7 +2,7 @@ from typing import Any, Callable, cast from quantum_circuit.classical_register import ClassicalRegister from quantum_circuit.quantum_circuit import QuantumCircuit -from quantum_circuit.quantum_register import QuantumRegister +from quantum_circuit.quantum_register import QuantumRegister, QiskitQubit from symbols.types import Qubit, Quint, Qustring, QutesDataType from qiskit import IBMQ, Aer, QiskitError, transpile from qiskit.primitives import Sampler @@ -219,20 +219,20 @@ def push_pauliy_operation(self, quantum_register : QuantumRegister) -> None: def push_pauliz_operation(self, quantum_register : QuantumRegister) -> None: self._current_operation_stack.append(lambda circuit : cast(QuantumCircuit, circuit).z(quantum_register)) - def push_MCZ_operation(self, quantum_registers : list[QuantumRegister]) -> None: - mcz_gate = MCMT(ZGate(), sum([q.size for q in quantum_registers]) - 1, 1) + def push_MCZ_operation(self, quantum_registers : list[QuantumRegister] | list[QiskitQubit]) -> None: + mcz_gate = MCMT(ZGate(), sum([1 if isinstance(q, QiskitQubit) else q.size for q in quantum_registers]) - 1, 1) self._current_operation_stack.append(lambda circuit : cast(QuantumCircuit, circuit).compose(mcz_gate, unwrap(quantum_registers), inplace=True)) - def push_MCX_operation(self, quantum_registers : list[QuantumRegister]) -> None: - mcx_gate = MCMT(XGate(), sum([len(q) for q in quantum_registers]) - 1, 1) + def push_MCX_operation(self, quantum_registers : list[QuantumRegister] | list[QiskitQubit]) -> None: + mcx_gate = MCMT(XGate(), sum([1 if isinstance(q, QiskitQubit) else q.size for q in quantum_registers]) - 1, 1) self._current_operation_stack.append(lambda circuit : cast(QuantumCircuit, circuit).compose(mcx_gate, unwrap(quantum_registers), inplace=True)) - def push_MCY_operation(self, quantum_registers : list[QuantumRegister]) -> None: - mcy_gate = MCMT(YGate(), sum([q.size for q in quantum_registers]) - 1, 1) + def push_MCY_operation(self, quantum_registers : list[QuantumRegister] | list[QiskitQubit]) -> None: + mcy_gate = MCMT(YGate(), sum([1 if isinstance(q, QiskitQubit) else q.size for q in quantum_registers]) - 1, 1) self._current_operation_stack.append(lambda circuit : cast(QuantumCircuit, circuit).compose(mcy_gate, unwrap(quantum_registers), inplace=True)) - def push_MCP_operation(self, theta, quantum_registers : list[QuantumRegister]) -> None: - mcp_gate = MCMT(PhaseGate(theta), sum([q.size for q in quantum_registers]) - 1, 1) + def push_MCP_operation(self, theta, quantum_registers : list[QuantumRegister] | list[QiskitQubit]) -> None: + mcp_gate = MCMT(PhaseGate(theta), sum([1 if isinstance(q, QiskitQubit) else q.size for q in quantum_registers]) - 1, 1) self._current_operation_stack.append(lambda circuit : cast(QuantumCircuit, circuit).compose(mcp_gate, unwrap(quantum_registers), inplace=True)) def push_hadamard_operation(self, quantum_register : QuantumRegister) -> None: diff --git a/src/quantum_circuit/quantum_register.py b/src/quantum_circuit/quantum_register.py index ba31f43..7a18f4c 100644 --- a/src/quantum_circuit/quantum_register.py +++ b/src/quantum_circuit/quantum_register.py @@ -1,5 +1,7 @@ from qiskit import QuantumRegister as qr from quantum_circuit.classical_register import ClassicalRegister +from qiskit.circuit.quantumregister import Qubit as QiskitQubit + class QuantumRegister(qr): def __init__(self, size, var_name, bits = None): @@ -8,4 +10,3 @@ def __init__(self, size, var_name, bits = None): def __len__(self): return self.size - \ No newline at end of file