- Depends only on numpy and matplotlib (and pytest for unit tests).
- Pure functions only (always return the same output for each input, with no side effects).
- Some exceptional functions that are not pure have names beginning with '_'.
- No new classes are introduced except for MPS. (state vectors, density matrices, and operators are all numpy.array.)
- All functions are less than 30 lines.
-
prerequisites
- python 3.8 or later
-
installation
$ pip install .
-
for development
$ pip install matplotlib numpy pytest black ruff wheel $ pip install --no-build-isolation -ve .
-
tests
$ pip install .[dev] $ pytest
-
examples
$ python3 example/simple.py $ python3 example/grover.py
-
state vector: numpy.ndarray
- number of legs: n + 1
- shape: [2,2,...,2,1]
-
density matrix: numpy.ndarray
- number of legs: 2 * n + 2
- shape: [2,2,...,2,1,1]
-
operator: numpy.ndarray
- number of legs: 2 * n
- shape: [2,2,...,2]
where n is the number of qubits.