!pip install quri-parts[qulacs]
!pip install exrex
Command | Quantum Circuit Manipulation |
---|---|
> | Make the next qubit the target of operation (pointer +1 ) |
< | Make the previous qubit the target of operation (pointer -1) |
+, H | Apply Hadamard gate |
~, T | Apply |
@, C | Apply CNOT gate (target is the next qubit or specified by following number) |
#, N | Apply random Pauli gate (error rate 0.1) |
: | Estimate measurements from state vector (no actual measurement) |
, | Initialize state vector |
; | State vector randomization |
[ | Start of loop |
] | Conditional loop termination (exits loop if measured value is 0, otherwise returns to beginning of loop) |
? | Hadamard gate or |
! | Randomly move the qubit (pointer) to be manipulated |
* | Randomly move execution point |
# Instantiate class
num = 5
qf = QF(num, regex=False, debug=False)
# Execute code
code = "[+!?~#!~@:]"
state, history, command, circuit = qf.parse(code)
# Output history of state vector
for i, s in enumerate(history):
print(f"Step {i}: {s}")
This project is licensed under the MIT License - see the LICENSE file for details.