Beispiel #1
0
    def __init__(self, qubit_map, initial_state=0):
        self.qubit_map = qubit_map
        self.n = len(qubit_map)

        self.tableau = clifford_tableau.CliffordTableau(self.n, initial_state)
        self.ch_form = stabilizer_state_ch_form.StabilizerStateChForm(
            self.n, initial_state)
Beispiel #2
0
def _final_clifford_tableau(
        circuit: Circuit,
        qubit_map) -> Optional[clifford_tableau.CliffordTableau]:
    """Evolves a default CliffordTableau through the input circuit.

    Initializes a CliffordTableau with default args for the given qubits and
    evolves it by having each operation act on the tableau.

    Args:
        circuit: An input circuit that acts on the zero state
        qubit_map: A map from qid to the qubit index for the above circuit

    Returns:
        None if any of the operations can not act on a CliffordTableau, returns
        the tableau otherwise."""

    tableau = clifford_tableau.CliffordTableau(len(qubit_map))
    for op in circuit.all_operations():
        try:
            args = act_on_clifford_tableau_args.ActOnCliffordTableauArgs(
                tableau=tableau,
                axes=[qubit_map[qid] for qid in op.qubits],  # type: ignore
                prng=np.random.RandomState(),
                log_of_measurement_results={},
            )
            protocols.act_on(op, args, allow_decompose=True)
        except TypeError:
            return None
    return tableau