py_alqorithms.basis_rotations_from_z_basis

py_alqorithms.basis_rotations_from_z_basis(pauli_products, qubit_mapping=None)

Creates a the circuit of basis rotations from Z basis to measurement basis.

To measure a product of general products of Pauli operators, the local basis of each qubit must be transformed so that the available Z-measurement corresponds to the measurement of the Pauli operator that should be measured.

The circuit can transform the local bases for several PauliProducts at the same time, as long as the PauliProducts are compatible. Two PauliProducts are compatible if for each qubit (or spin) in the PauliProduct the both PauliProducts have either the same PauliOperator (X, Y, Z) or at least one has the identity I.

The function returns an error when the PauliProducts are not compatible.

The resulting circuit will rotate each qubit into a new basis so that a Z-Measurement will be equivalent to a X, Y or Z measurement in the original basis, depending on which Pauli Operator is supposed to be measured.

Parameters:
  • pauli_products (List[PauliProduct]) -- The PauliProducts that should be measured by the circuit

  • qubit_mapping (Optional[Dict[int, int]]) -- Optional mapping of the qubits

Returns:

the measurement circuit produced.

Return type:

Circuit

Raises:
  • PyTypeError -- Error converting the list of PauliProducts.

  • PyValueError -- PauliProducts can not be measured in same circuit with chosen method.