quairkit.operator.gate.custom

The source file of the oracle class and the control oracle class.

class quairkit.operator.gate.custom.Oracle(oracle, system_idx=None, acted_system_dim=2, gate_info=None)

An oracle as a gate.

Parameters:
oracle : Tensor

Unitary oracle to be implemented.

system_idx : Iterable[Iterable[int]] | Iterable[int] | int

Indices of the systems on which the gates are applied.

acted_system_dim : List[int] | int

dimension of systems that this gate acts on. Can be a list of system dimensions or an int representing the dimension of all systems. Defaults to be qubit case.

class quairkit.operator.gate.custom.ControlOracle(oracle, system_idx, acted_system_dim=2, proj=None, gate_info=None)

A controlled oracle as a gate.

Args:

oracle: Unitary oracle to be implemented. system_idx: Indices of the systems on which the gates are applied. The first element in the list is the control system,

defaulting to :math:`|d-1

angle langle d-1|` as the control qubit,

while the remaining elements represent the oracle system.

acted_system_dim: dimension of systems that this gate acts on. Can be a list of system dimensions

or an int representing the dimension of all systems. Defaults to be qubit case.

proj: Projector matrix for the control qubit. Defaults to None.

class quairkit.operator.gate.custom.ParamOracle(generator, param=None, num_acted_param=1, param_sharing=False, system_idx=None, acted_system_dim=2, gate_info=None)

An parameterized oracle as a gate

Parameters:
generator : Callable[[Tensor], Tensor]

function that generates the oracle.

param : Tensor | float | List[float]

input parameters of quantum parameterized gates. Defaults to None i.e. randomized.

system_idx : Iterable[Iterable[int]] | Iterable[int] | int

indices of the system on which this gate acts on. Defaults to None i.e. list(range(num_systems)).

num_acted_param : int

the number of parameters required for a single operation.

param_sharing : bool

whether all operations are shared by the same parameter set.

acted_system_dim : List[int] | int

dimension of systems that this gate acts on. Can be a list of system dimensions or an int representing the dimension of all systems. Defaults to be qubit case.

gate_info : Dict

information of this gate that will be placed into the gate history or plotted by a Circuit. Defaults to None.

class quairkit.operator.gate.custom.UniversalQudits(system_idx, acted_system_dim, param=None, param_sharing=False)

A collection of universal qudit gates. One of such a gate requires \(d^2 - 1\) parameters.

Parameters:
system_idx : Iterable[int] | str | None

Indices of the qubits on which the gates are applied. Defaults to the first qubit.

param : Tensor | float | None

Parameters of the gates. Defaults to None.

param_sharing : bool | None

Whether gates in the same layer share a parameter. Defaults to False.

acted_system_dim : Iterable[int]

dimension of systems that this gate acts on. Can be a list of system dimensions or an int representing the dimension of all systems. Defaults to be qubit case.