forked from ScQ-Cloud/pyquafu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add README of Clifford simulator
provided by Yanglin Zhang, to be integrated into UserGuide in future version
- Loading branch information
1 parent
4f72c6e
commit ee1111d
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Clifford Simulator | ||
|
||
Usage of Clifford simulator in ``pyquafu`` is very similar with the default simulator, but applies only to circuits with a limited gate set. | ||
|
||
## Supported Gates | ||
|
||
### x | ||
|
||
The Pauli X gate. The bit flip gate. | ||
|
||
### y | ||
|
||
The Pauli Y gate. | ||
|
||
### z | ||
|
||
The Pauli Z gate. The phase flip gate | ||
|
||
### h | ||
|
||
The Hadamard gate. Swap the X and Z axes. Alternate name: `h_xz` | ||
|
||
### h_yz | ||
|
||
The variant of the Hadamard gate that swaps the Y and Z axes (instead of X and Z) | ||
|
||
### s | ||
|
||
Principal square root of Z gate. Phases the amplitue of |1> by i. Alternate name: `sqrt_z` | ||
|
||
### s_dag | ||
|
||
Adjoint of the principal square root of z gate. Phases the amplitube of |1> by -i. Alternate name: `sqrt_z_dag` | ||
|
||
### cnot | ||
|
||
The Z-controlled X gate. Applies an X gate to the target if the control is in the |1> state. Equivalently: negates the amplitude of the |1>|-> state. The first qubit is called the control, and the second qubit is the target. Alternate name: `cx`, `zcx` | ||
|
||
### swap | ||
|
||
Swap two qubits. | ||
|
||
### measure | ||
|
||
Z-basis measurement. Projects each target qubit into |0> or |1> and reports its value (false=|0>, true=|1>). | ||
|
||
### reset | ||
|
||
Z-basis reset. Forces each target qubit into the |0> state by silently measuring it in the Z basis and applying an X gate if it ended up in the |1> state. | ||
|
||
## Simple Example | ||
|
||
```python | ||
from quafu import QuantumCircuit, simulate | ||
|
||
qc = QuantumCircuit(4, 4) | ||
qc.x(0) | ||
qc.x(1) | ||
qc.measure([1, 2], [1, 0]) | ||
qc.measure([3, 0], [2, 3]) | ||
|
||
result = simulate(qc=qc, shots=10, simulator="qfvm_clifford", output="count_dict") | ||
counts = result.count | ||
|
||
# {"0101": 10} | ||
print(counts) | ||
``` |