A %quantum magic command for evaluating basic quantum circuit calculations using numpy. Conveniently displays vector data in dirac notation and pretty prints array values as squares and fractions where possible.
import quantum
%quantum X0 |0>|1>
%quantum CX01 H0 |00>1/√2 |00> + 1/√2 |11>
# Index zero starts from left
%quantum X0 X2 X4 |000000>|101010>
%quantum X0*X1*X2[farray([
[0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0]
])]
See notebooks/example.ipynb for more examples.
To generate a Jupyter notebook from this README.md file, run
pip install jupytext
jupytext README.md --to ipynb --output notebooks/README.ipynb