qml.estimator.ops.Pow

class Pow(base_op, pow_z)[source]

Bases: ResourceOperator

Resource class for the symbolic Pow operation.

This symbolic class can be used to represent some base operation raised to a power.

Parameters:
  • base_op (ResourceOperator) – The operator to exponentiate.

  • pow_z (int) – the exponent (default value is 1)

Resources:

The resources are determined as follows. If the power \(z = 0\), this corresponds to the identity gate which requires no resources. If the base operation class base_class implements the .pow_resource_decomp() method, then the resources are obtained from this. Otherwise, the resources of the operation raised to the power \(z\) are given by extracting the base operation’s resources (via Resources) and raising each operation to the same power.

See also

The corresponding PennyLane operation Pow.

Example

The operation raised to a power \(z\) can be constructed like this:

>>> import pennylane.estimator as qre
>>> z = qre.Z()
>>> z_2 = qre.Pow(z, 2)
>>> z_5 = qre.Pow(z, 5)

We obtain the expected resources.

>>> print(qre.estimate(z_2, gate_set={"Identity", "Z"}))
--- Resources: ---
 Total wires: 1
    algorithmic wires: 1
    allocated wires: 0
             zero state: 0
             any state: 0
 Total gates : 1
  'Identity': 1
>>>
>>> print(qre.estimate(z_5, gate_set={"Identity", "Z"}))
--- Resources: ---
 Total wires: 1
    algorithmic wires: 1
    allocated wires: 0
             zero state: 0
             any state: 0
 Total gates : 1
  'Z': 1

resource_keys

resource_params

Returns a dictionary containing the minimal information needed to compute the resources.

resource_keys = {'base_cmpr_op', 'z'}
resource_params

Returns a dictionary containing the minimal information needed to compute the resources.

Returns:

A dictionary containing the resource parameters:
  • base_class (Type[ResourceOperator]): The class type of the base operator to be raised to some power.

  • base_params (dict): the resource parameters required to extract the cost of the base operator

  • z (int): the power that the operator is being raised to

Return type:

dict

pow_resource_decomp(pow_z, ...)

Returns a list representing the resources of the operator.

resource_decomp(base_cmpr_op, pow_z, **kwargs)

Returns a list representing the resources of the operator.

resource_rep(base_cmpr_op, pow_z)

Returns a compressed representation containing only the parameters of the operator that are needed to compute a resource estimation.

tracking_name(base_cmpr_op, pow_z)

Returns the tracking name built with the operator's parameters.

classmethod pow_resource_decomp(pow_z, target_resource_params)[source]

Returns a list representing the resources of the operator. Each object represents a quantum gate and the number of times it occurs in the decomposition.

Parameters:
  • pow_z (int) – The exponent that the base operator is being raised to. Default value is 1.

  • target_resource_params (dict) – A dictionary containing the resource parameters of the target operator.

Resources:

The resources are derived by simply adding together the \(z\) exponent and the \(z_{0}\) exponent into a single instance of Pow gate, raising the base operator to the power \(z + z_{0}\).

Returns:

A list of GateCount objects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.

Return type:

list[GateCount]

classmethod resource_decomp(base_cmpr_op, pow_z, **kwargs)[source]

Returns a list representing the resources of the operator. Each object represents a quantum gate and the number of times it occurs in the decomposition.

Parameters:
  • base_cmpr_op (CompressedResourceOp) – A compressed resource representation for the operator we want to exponentiate.

  • pow_z (float) – the exponent (default value is 1)

Resources:

The resources are determined as follows. If the power \(z = 0\), this corresponds to the identity gate which requires no resources. If the base operation class base_class implements the .pow_resource_decomp() method, then the resources are obtained from this. Otherwise, the resources of the operation raised to the power \(z\) are given by extracting the base operation’s resources (via Resources) and raising each operation to the same power.

Returns:

A list of GateCount objects, 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(base_cmpr_op, pow_z)[source]

Returns a compressed representation containing only the parameters of the operator that are needed to compute a resource estimation.

Parameters:
  • base_class (Type[ResourceOperator]) – The class type of the base operator to be raised to some power.

  • base_params (dict) – the resource parameters required to extract the cost of the base operator

  • pow_z (int) – the power that the operator is being raised to

Returns:

the operator in a compressed representation

Return type:

CompressedResourceOp

static tracking_name(base_cmpr_op, pow_z)[source]

Returns the tracking name built with the operator’s parameters.

Contents

Using PennyLane

Release news

Development

API

Internals