Skip to content

Basic grammar for expressing linear algebra for quantum circuits

License

Notifications You must be signed in to change notification settings

quantum-experiments/quantum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum calculator

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.

Example usage

import quantum
%quantum X0 |0>

|1>

Bell state

%quantum CX01 H0 |00>

1/√2 |00> + 1/√2 |11>

Multi-qubit gates

# Index zero starts from left
%quantum X0 X2 X4 |000000>

|101010>

Kronecker product

%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]
])]

Run examples

See notebooks/example.ipynb for more examples.

Generate README.ipynb

To generate a Jupyter notebook from this README.md file, run

pip install jupytext
jupytext README.md --to ipynb --output notebooks/README.ipynb

About

Basic grammar for expressing linear algebra for quantum circuits

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published