# cirq.PauliStringPhasor

An operation that phases the eigenstates of a Pauli string.

Inherits From: GateOperation, Operation

This class takes PauliString, which is a sequence of non-identity Pauli operators, potentially with a $$\pm 1$$ valued coefficient, acting on qubits.

The -1 eigenstates of the Pauli string will have their amplitude multiplied by e^(i pi exponent_neg) while +1 eigenstates of the Pauli string will have their amplitude multiplied by e^(i pi exponent_pos).

The class also takes a list of qubits, which can be a superset of those acted on by the provided PauliString. Those extra qubits are assumed to be acted upon via identity.

pauli_string The PauliString defining the positive and negative eigenspaces that will be independently phased.
qubits The qubits upon which the PauliStringPhasor acts. This must be a superset of the qubits of pauli_string. If None, it will use the qubits from pauli_string The pauli_string contains only the non-identity component of the phasor, while the qubits supplied here and not in pauli_string are acted upon by identity. The order of these qubits must match the order in pauli_string.
exponent_neg How much to phase vectors in the negative eigenspace, in the form of the t in (-1)t = exp(i pi t).
exponent_pos How much to phase vectors in the positive eigenspace, in the form of the t in (-1)t = exp(i pi t).

ValueError If coefficient is not 1 or -1 or the qubits of pauli_string are not a subset of qubits.

classical_controls The classical controls gating this operation.
exponent_neg The negative exponent.
exponent_pos The positive exponent.
exponent_relative The relative exponent between negative and positive exponents.
gate The gate applied by the operation.
pauli_string The underlying pauli string.
qubits The qubits targeted by the operation.
tags Returns a tuple of the operation's tags.
untagged Returns the underlying operation without any tags.

## Methods

### can_merge_with

View source

Checks whether the underlying PauliStrings can be merged.

### controlled_by

View source

Returns a controlled version of this operation. If no control_qubits are specified, returns self.

Args
*control_qubits Qubits to control the operation by. Required.
control_values For which control qubit values to apply the operation. A sequence of the same length as control_qubits where each entry is an integer (or set of integers) corresponding to the qubit value (or set of possible values) where that control is enabled. When all controls are enabled, the operation is applied. If unspecified, control values default to 1.

### equal_up_to_global_phase

View source

Checks equality of two PauliStringPhasors, up to global phase.

### map_qubits

View source

Maps the qubits inside the PauliStringPhasor.

Args
qubit_map A map from the qubits in the phasor to new qubits.

Returns
A new PauliStringPhasor with remapped qubits.

Raises
ValueError If the map does not contain an entry for all the qubits in the phasor.

### merged_with

View source

Merges two PauliStringPhasors.

### pass_operations_over

View source

Determines how the Pauli phasor changes when conjugated by Cliffords.

The output and input pauli phasors are related by a circuit equivalence. In particular, this circuit:

───ops───INPUT_PAULI_PHASOR───


will be equivalent to this circuit:

───OUTPUT_PAULI_PHASOR───ops───


up to global phase (assuming after_to_before is not set).

If ops together have matrix C, the Pauli string has matrix P, and the output Pauli string has matrix P', then P' == C^-1 P C up to global phase.

Setting after_to_before inverts the relationship, so that the output is the input and the input is the output. Equivalently, it inverts C.

Args
ops The operations to move over the string.
after_to_before Determines whether the operations start after the pauli string, instead of before (and so are moving in the opposite direction).

### transform_qubits

View source

Returns the same operation, but with different qubits.

Args
qubit_map A function or a dict mapping each current qubit into a desired new qubit.

Returns
The receiving operation but with qubits transformed by the given function.

Raises
TypeError qubit_map was not a function or dict mapping qubits to qubits.

### validate_args

View source

Raises an exception if the qubits don't match this operation's qid shape.

Call this method from a subclass's with_qubits method.

Args
qubits The new qids for the operation.

Raises
ValueError The operation had qids that don't match it's qid shape.

### with_classical_controls

View source

Returns a classically controlled version of this operation.

An operation that is classically controlled is executed iff all conditions evaluate to True. Conditions can be either a measurement key or a user-specified cirq.Condition. A measurement key evaluates to True iff any qubit in the corresponding measurement operation evaluated to a non-zero value; cirq.Condition supports more complex, user-defined conditions.

If no conditions are specified, returns self.

The classical control will remove any tags on the existing operation, since tags are fragile, and we always opt to get rid of the tags when the underlying operation is changed.

Args
*conditions A list of measurement keys, strings that can be parsed into measurement keys, or sympy expressions where the free symbols are measurement key strings.

Returns
A ClassicallyControlledOperation wrapping the operation. If no conditions are specified, returns self.

View source

### with_probability

View source

Creates a probabalistic channel with this operation.

Args
probability floating point value between 0 and 1, giving the probability this gate is applied.

Returns
cirq.RandomGateChannel that applies self with probability probability and the identity with probability 1-p.

Raises
NotImplementedError if called on an operation that lacks a gate.

### with_qubits

View source

Returns the same operation, but applied to different qubits.

Args
*new_qubits The new qubits to apply the operation to. The order must exactly match the order of qubits returned from the operation's qubits property.

### with_tags

View source

Creates a new TaggedOperation, with this op and the specified tags.

This method can be used to attach meta-data to specific operations without affecting their functionality. The intended usage is to attach classes intended for this purpose or strings to mark operations for specific usage that will be recognized by consumers. Specific examples include ignoring this operation in optimization passes, hardware-specific functionality, or circuit diagram customizability.

Tags can be a list of any type of object that is useful to identify this operation as long as the type is hashable. If you wish the resulting operation to be eventually serialized into JSON, you should also restrict the operation to be JSON serializable.

Args
*new_tags The tags to wrap this operation in.

### without_classical_controls

View source

Removes all classical controls from the operation.

This function removes all classical controls gating the operation. It acts recursively, so that all classical control wrappers are always removed from the current operation.

If there are no classical controls on the operation, it will return self.

Since tags are fragile, this will also remove any tags from the operation, when called on TaggedOperation (unless there are no classical controls on it). If a TaggedOperation is under all the classical control layers, that TaggedOperation will be returned from this function.

Returns
The operation with all classical controls removed.

View source

View source

View source

### __pow__

View source

Raise gate to a power, then reapply to the same qubits.

Only works if the gate implements cirq.ExtrapolatableEffect. For extrapolatable gate G this means the following two are equivalent:

(G ** 1.5)(qubit)  or  G(qubit) ** 1.5


Args
exponent The amount to scale the gate's effect by.

Returns
A new operation on the same qubits with the scaled gate.

### __rmul__

View source

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]