Supports 3 kinds of operations
- apply a logic gate to any subset of qubits
- measure a qubit and write the result into a classical bit
- apply logic gates conditionally based on the value of a classical bit
Examples of bell circuit and teleportation circuit in src/main.ts.
Input wavefunction -
Output wavefunction -
3 qubits - p
, q
, r
Alice holds p
and q
, Bob holds r
. We want to teleport the state of the qubit p
to the qubit r
.
Input wavefunction -
One possible output wavefunction - p
has collapsed into the state q
has collapsed into the state r
has got p
's initial wavefunction.
Running main
$ tsc
$ node dist/main.js
Simulating bell circuit...
Wavefunction before the simulation: 1|00>
Wavefunction after simulation: 0.7071|00> + 0.7071|11>
Simulating teleportation circuit...
Wavefunction before the simulation: 0.6325|000> + 0.7746|100>
Wavefunction after simulation: 0.6325|100> + 0.7746|101>
Running tests
$ npx jest