ket.qulib¶
Quantum library.
Utilities for preparing quantum states and building quantum algorithms.
Modules ket.qulib
¶
Functions ket.qulib
¶
|
Draw a quantum gate using Qiskit. |
|
Get the matrix representation of a quantum gate. |
- draw(gate: Callable, qubits: int | list[int], args: tuple = (), *, qpu_size: int | None = None, u4_gate: Literal['CX', 'CZ'] | None = None, u2_gates: Literal['ZYZ', 'RzSx'] | None = None, coupling_graph: list[tuple[int, int]] | None = None, title: str | None = None, keep_order: bool = True, **kwargs)¶
Draw a quantum gate using Qiskit.
Note
This method requires additional dependencies from
ket-lang[plot]
.Install with:
pip install ket-lang[plot]
.- Parameters:
gate – Quantum gate function.
qubits – Number of qubits.
args – Classical arguments to pass to the gate function.
qpu_size – Size of the quantum processing unit (QPU). If specified, the number of qubits will be adjusted to fit the QPU size.
u4_gate – Type of U4 gate to use, either “CX” or “CZ”.
u2_gates – Type of U2 gates to use, either “ZYZ” or “RzSx”.
coupling_graph – Coupling graph of the QPU, specified as a list of tuples representing connected qubits.
title – Title for the circuit diagram.
keep_order – Maintain the gate call order.
**kwargs – Keyword arguments to pass to the Qiskit drawer.
- Returns:
Qiskit circuit diagram of the quantum gate.
- dump_matrix(gate: Callable, num_qubits: int | list[int] = 1, args=(), process: Process | None = None) list[list[complex]] ¶
Get the matrix representation of a quantum gate.
This function calculates the matrix representation of a quantum gate.
- Parameters:
gate – Quantum gate operation to obtain the matrix for.
num_qubits – Number of qubits.
args – Classical arguments to pass to the gate function.
process – Quantum process used to generate the matrix.
- Returns:
Matrix representation of the quantum gate.