Skip to content

0.2.1

Compare
Choose a tag to compare
@thisac thisac released this 01 Jun 14:57

New Features

  • Measurement samples can be returned as bitstrings instead of integers in nested lists.

  • A density matrix representation of the state can be accessed via the Circuit.density_matrix
    property, for both pure and mixed states (with the former being lazily calculated from the state
    vector).

Upgrade Notes

  • Adds support for multi-qubit sampling in measurements. Measurement.sample() and
    Measurement.expval() are updated to accept a sequence of qubit indices to sample, sampling
    all measured qubits if none are given.

    circuit = Circuit(2, 2)
    
    with circuit.context as (q, c):
        ops.X(q[0])
        m = ops.Measurement(q) | c
    
    simulate(circuit)
    
    m.sample(num_samples=3, as_bitstring=True)
    # ['10', '10', '10']
  • The state is now stored in the Circuit object (same as the bits/measurement results) instead
    of being returned by the simulate() function. It can now be accessed via the
    Circuit.state property.