qml.estimator.ops.PCPhase¶
- class PCPhase(num_wires, dim, rotation_precision=None, wires=None)[source]
Bases:
ResourceOperatorA resource operator representing a projector-controlled phase gate.
This gate applies a complex phase \(e^{i\phi}\) to the first
dimbasis vectors of the input state while applying a complex phase \(e^{-i \phi}\) to the remaining basis vectors. For example, consider the 2-qubit case wheredim = 3:\[\begin{split}\Pi(\phi) = \begin{bmatrix} e^{i\phi} & 0 & 0 & 0 \\ 0 & e^{i\phi} & 0 & 0 \\ 0 & 0 & e^{i\phi} & 0 \\ 0 & 0 & 0 & e^{-i\phi} \end{bmatrix}.\end{split}\]This can also be written as \(\Pi(\phi) = \exp(i\phi(2\Pi-\mathbb{I}_N))\), where \(N=2^n\) is the Hilbert space dimension for \(n\) qubits and \(\Pi\) is the diagonal projector with
dimones andN-dimzeros.- Parameters:
num_wires (int) – the number of wires this operator acts on
dim (int) – the dimension of the target subspace
rotation_precision (float | None) – The error threshold for the approximate Clifford + T decomposition of the
PhaseShiftgates used to implement this operation.wires (WiresLike | None) – the wire the operation acts on
- Resources:
The resources are derived from the decomposition of the generator \(G\) of the
PCPhasegate into multiple projectors, which generate (multi-controlled)PhaseShiftgates, potentially complemented with (non-controlled)Xgates and/or a global phase. The generator is given as \(G = 2 \Pi - \mathbb{I}_N\), where \(\Pi\) is a projector. The projector \(\Pi\) is decomposed into sums and differences of powers of two, which correspond to multi-controlledPhaseShiftgates.
See also
The corresponding PennyLane operation
PCPhase.Example
The resources for this operation are computed using:
>>> import pennylane.estimator as qre >>> pc_phase = qre.PCPhase(num_wires=2, dim=2, rotation_precision=1e-5) >>> print(qre.estimate(pc_phase)) --- Resources: --- Total wires: 2 algorithmic wires: 2 allocated wires: 0 zero state: 0 any state: 0 Total gates : 28 'T': 28
Attributes
Returns a dictionary containing the minimal information needed to compute the resources.
- resource_keys = {'dim', 'num_wires', 'rotation_precision'}¶
- resource_params¶
Returns a dictionary containing the minimal information needed to compute the resources.
- Returns:
- A dictionary containing the resource parameters:
num_wires (int): the number of wires this operator acts on
dim (int): the dimension of the target subspace
rotation_precision(float | None): The error threshold for the approximate Clifford + T decomposition of the
PhaseShiftgates used to implement this operation.
- Return type:
dict
Methods
resource_decomp(num_wires, dim[, ...])Returns a list of GateCount objects representing the operator's resources.
resource_rep(num_wires, dim[, ...])Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.
- classmethod resource_decomp(num_wires, dim, rotation_precision=None)[source]¶
Returns a list of GateCount objects representing the operator’s resources.
- Parameters:
num_wires (int) – the number of wires this operator acts on
dim (int) – the dimension of the target subspace
rotation_precision (float | None) – The error threshold for the approximate Clifford + T decomposition of the
PhaseShiftgates used to implement this operation.
- Resources:
The resources are derived from the decomposition of the generator \(G\) of the
PCPhasegate into multiple projectors, which generate (multi-controlled)PhaseShiftgates, potentially complemented with (non-controlled)Xgates and/or a global phase. The generator is given as \(G = 2 \Pi - \mathbb{I}_N\), where \(\Pi\) is a projector. The projector \(\Pi\) is decomposed into sums and differences of powers of two, which correspond to multi-controlledPhaseShiftgates.
- Returns:
A list of
GateCountobjects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.- Return type:
list[
GateCount]
- classmethod resource_rep(num_wires, dim, rotation_precision=None)[source]¶
Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.
- Parameters:
num_wires (int) – the number of wires this operator acts on
dim (int) – the dimension of the target subspace
rotation_precision (float | None) – The error threshold for the approximate Clifford + T decomposition of the
PhaseShiftgates used to implement this operation.
- Returns:
the operator in a compressed representation
- Return type: