def _final_stabilizer_state_ch_form( circuit: Circuit, qubit_map) -> Optional[stabilizer_state_ch_form.StabilizerStateChForm]: """Evolves a default StabilizerStateChForm through the input circuit. Initializes a StabilizerStateChForm with default args for the given qubits and evolves it by having each operation act on the state. 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 StabilizerStateChForm, returns the StabilizerStateChForm otherwise.""" stabilizer_ch_form = stabilizer_state_ch_form.StabilizerStateChForm( len(qubit_map)) for op in circuit.all_operations(): try: args = act_on_stabilizer_ch_form_args.ActOnStabilizerCHFormArgs( state=stabilizer_ch_form, axes=[qubit_map[qid] for qid in op.qubits], prng=np.random.RandomState(), log_of_measurement_results={}, ) protocols.act_on(op, args, allow_decompose=True) except TypeError: return None return stabilizer_ch_form
def _final_stabilizer_state_ch_form( circuit: Circuit, qubit_map) -> Optional[stabilizer_state_ch_form.StabilizerStateChForm]: """Evolves a default StabilizerStateChForm through the input circuit. Initializes a StabilizerStateChForm with default args for the given qubits and evolves it by having each operation act on the state. 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 StabilizerStateChForm, returns the StabilizerStateChForm otherwise.""" stabilizer_ch_form = stabilizer_state_ch_form.StabilizerStateChForm( len(qubit_map)) args = stabilizer_ch_form_simulation_state.StabilizerChFormSimulationState( qubits=list(qubit_map.keys()), prng=np.random.RandomState(), initial_state=stabilizer_ch_form, ) for op in circuit.all_operations(): try: protocols.act_on(op, args, allow_decompose=True) except TypeError: return None return stabilizer_ch_form
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
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)) args = clifford_tableau_simulation_state.CliffordTableauSimulationState( tableau=tableau, qubits=list(qubit_map.keys()), prng=np.random.RandomState()) for op in circuit.all_operations(): try: protocols.act_on(op, args, allow_decompose=True) except TypeError: return None return tableau