quairkit.operator.gate.base¶
The source file of the basic class for the quantum gates.
-
class quairkit.operator.gate.base.Gate(matrix=
None
, system_idx=None
, acted_system_dim=2
, check_legality=True
, gate_info=None
)¶ Base class for quantum gates.
- Parameters:¶
- matrix : Tensor¶
the matrix of this gate. Defaults to
None
i.e. not specified.- system_idx : Iterable[Iterable[int]] | Iterable[int] | int¶
indices of the systems that this gate acts on. Defaults to
None
. i.e. list(range(# of acted systems)).- 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.
- check_legality : bool¶
whether check the completeness of the matrix if provided. Defaults to
True
.- gate_info : dict¶
information of this gate that will be placed into the gate history or plotted by a Circuit. Defaults to
None
.
- property matrix : Tensor¶
Unitary matrix of this gate
- Raises:¶
ValueError – Need to specify the matrix form in this Gate instance.
- gate_history_generation()¶
determine self.gate_history
-
class quairkit.operator.gate.base.ParamGate(generator, param=
None
, num_acted_param=1
, param_sharing=False
, system_idx=None
, acted_system_dim=2
, check_legality=True
, gate_info=None
)¶ Base class for quantum parameterized gates.
- Parameters:¶
- generator : Callable[[Tensor], Tensor]¶
function that generates the unitary matrix of this gate.
- param : Tensor | float | List[float]¶
input parameters of quantum parameterized gates. Defaults to
None
i.e. randomized.- qubits_idx
indices of the qubits on which this gate acts on. Defaults to
None
. i.e. list(range(num_acted_qubits)).- 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.
- check_legality : bool¶
whether check the completeness of the matrix if provided. Defaults to
True
.- gate_info : dict¶
information of this gate that will be placed into the gate history or plotted by a Circuit. Defaults to
None
.
- gate_history_generation()¶
determine self.gate_history when gate is parameterized