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, acted_system_dim=2, gate_info=None)

An oracle as a gate.

Parameters:
oracle : Tensor

Unitary oracle to be implemented.

system_idx : List[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.

property info : OperatorInfoType

Information of this gate.

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

A controlled oracle as a gate.

Parameters:
oracle : Tensor

Unitary oracle to be implemented.

system_idx : List[int | List[int]]

Indices of the systems on which the gates are applied. The first element in the list is the control system, represented by a int or a list of ints, and the remaining elements represent the oracle system.

index : int

control index that activates the matrix.

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 | None

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.ParamOracle(generator, system_idx, param=None, num_acted_param=1, acted_system_dim=2, gate_info=None, support_batch=False)

An parameterized oracle as a gate

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

function that generates the oracle.

system_idx : List[int] | int

indices of the system on which this gate acts on.

param : Tensor | float | List[float]

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

num_acted_param : int

the number of parameters required for a single operation.

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.

support_batch : bool

whether the generator supports batched input. Defaults to False.

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

An parameterized oracle as a gate

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

function that generates the oracle.

system_idx : List[int] | int

Indices of the systems on which the gates are applied. The first element in the list is the control system, represented by a int or a list of ints, and the remaining elements represent the oracle system.

index : int

control index that activates the matrix.

param : Tensor | float | List[float]

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

num_acted_param : int

the number of parameters required for a single operation.

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.

support_batch : bool

whether the generator supports batched input. Defaults to False.

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.

class quairkit.operator.gate.custom.Permutation(perm, system_idx, acted_system_dim=2)

permutation matrix as a gate.

Parameters:
perm : List[int]

A list representing the permutation of subsystems. For example, [1, 0, 2] swaps the first two subsystems.

system_idx : List[int | List[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.