qml.estimator.templates.SemiAdder

class SemiAdder(max_register_size, wires=None)[source]

Bases: ResourceOperator

Resource class for the SemiAdder gate.

Parameters:
  • max_register_size (int) – the size of the larger of the two registers being added together

  • wires (Sequence[int], None) – the wires the operation acts on

Resources:

The resources are obtained from figures 1 and 2 in Gidney (2018).

See also

The corresponding PennyLane operation SemiAdder.

Example

The resources for this operation are computed using:

>>> import pennylane.estimator as qre
>>> semi_add = qre.SemiAdder(max_register_size=4)
>>> print(qre.estimate(semi_add))
--- Resources: ---
Total wires: 11
    algorithmic wires: 8
    allocated wires: 3
    zero state: 3
    any state: 0
Total gates : 30
'Toffoli': 3,
'CNOT': 18,
'Hadamard': 9

resource_keys

resource_params

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

resource_keys = {'max_register_size'}
resource_params

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

Returns:

A dictionary containing the resource parameters:
  • max_register_size (int): the size of the larger of the two registers being added together

Return type:

dict

controlled_resource_decomp(num_ctrl_wires, ...)

Returns a list representing the resources of the operator.

resource_decomp(max_register_size)

Returns a list representing the resources of the operator.

resource_rep(max_register_size)

Returns a compressed representation containing only the parameters of the Operator that are needed to compute the resources.

classmethod controlled_resource_decomp(num_ctrl_wires, num_zero_ctrl, target_resource_params)[source]

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

Parameters:
  • num_ctrl_wires (int) – the number of qubits the operation is controlled on

  • num_zero_ctrl (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state

  • target_resource_params (dict) – dictionary containing the size of the larger of the two registers being added together

Resources:

The resources are obtained from figure 4a in Gidney (2018).

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(max_register_size)[source]

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

Parameters:

max_register_size (int) – the size of the larger of the two registers being added together

Resources:

The resources are obtained from figures 1 and 2 in Gidney (2018).

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(max_register_size)[source]

Returns a compressed representation containing only the parameters of the Operator that are needed to compute the resources.

Parameters:

max_register_size (int) – the size of the larger of the two registers being added together

Returns:

the operator in a compressed representation

Return type:

CompressedResourceOp

Contents

Using PennyLane

Release news

Development

API

Internals