quara.objects.gate_typical module
- calc_1qutrit_single_gellmann_hamiltonian_mat_from_levels_axis_angle(levels, axis, angle)[source]
return a 1-qutrit Hamiltonian matrix for the axis, levels, and angle.
- Parameters
levels (str) –
axis (str) –
angle (str) –
- Return type
numpy.ndarray
- calc_angle_from_str_to_float(angle_str)[source]
return angle value from angle string
- Parameters
angle_str (str) –
- Return type
float
- calc_base_matrix_1qutrit(levels, axis)[source]
Return a base matrix for 1-qutrit Hamiltonian.
- Parameters
axis (str) – specifies “i”, “x”, “y”, or “z”.
levels (str) – specifies levels for the axis, limited to [“01”, “12”, or “02”] for axis = “x”, “y”, or “z”. levels = None for “i”.
- Returns
The base matrix corresponding to the axis and levels, to be complex.
- Return type
np.ndarray((3,3), dtype=np.complex128)
- calc_base_matrix_1qutrit_identity()[source]
Return the identity matrix on a 1-qutrit system.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_x_01()[source]
Return the base matrix corresponding to the x-axis w.r.t. levels 0 and 1.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_x_02()[source]
Return the base matrix corresponding to the x-axis w.r.t. levels 0 and 2.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_x_12()[source]
Return the base matrix corresponding to the x-axis w.r.t. levels 1 and 2.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_y_01()[source]
Return the base matrix corresponding to the y-axis w.r.t. levels 0 and 1.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_y_02()[source]
Return the base matrix corresponding to the y-axis w.r.t. levels 0 and 2.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_y_12()[source]
Return the base matrix corresponding to the y-axis w.r.t. levels 1 and 2.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_z_01()[source]
Return the base matrix corresponding to the z-axis w.r.t. levels 0 and 1.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_z_02()[source]
Return the base matrix corresponding to the z-axis w.r.t. levels 0 and 2.
- Return type
numpy.ndarray
- calc_base_matrix_1qutrit_z_12()[source]
Return the base matrix corresponding to the z-axis w.r.t. levels 1 and 2.
- Return type
numpy.ndarray
- calc_coeff_from_angle_str(angle_str)[source]
return coeff = 0.5 * angle from angle_str.
- Parameters
angle_str (str) –
- Return type
float
- calc_decimal_number_from_pauli_symbol(symbol)[source]
Return the decimal number corresponding to a given pauli symbol.
- Parameters
symbol (str) – Ex. i, x, yz, xyz.
- Returns
int – Ex. 0, 1, 11, 27
- Return type
A decimal number
- calc_gate_from_hamiltonian_mat(c_sys, h, is_physicality_required=True)[source]
return a Gate class object for a given Hamiltonian matrix.
- Parameters
c_sys (CompositeSystem, whose basis must be Hermitian.) –
h (np.ndarray((dim, dim), dtype=np.complex128)) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
- Return type
- calc_gate_mat_from_hamiltonian_mat(h, to_basis)[source]
return a HS matrix of a gate for a given Hamiltonian matrix.
- Parameters
h (np.ndarray((dim dim), dtype=np.complex128)) – Hamiltonian matrix
to_basis (MatrixBasis, to be Hermitian) –
- Returns
- Return type
np.ndarray((dim^2, dim^2), dtype=np.float64)
- calc_gate_mat_from_unitary_mat(from_u, to_basis)[source]
Return the HS matrix for a gate represented by an unitary matrix.
- Parameters
from_u (np.ndarray((dim, dim), dtype=np.complex128)) – The unitary matrix, to be square complex np.ndarray.
to_basis (MatrixBasis) – The matrix basis for representing the HS matrix, to be orthonormal.
- Returns
The HS matrix of the gate corresponding to the unitary matrix.
- Return type
np.ndarray((dim^2, dim^2), dtype=np.complex128)
- calc_gate_mat_from_unitary_mat_with_hermitian_basis(from_u, to_basis)[source]
Return the HS matrix w.r.t. a Hermitian (orthonormal) matrix basis for a gate represented by an unitary matrix.
- Parameters
from_u (np.ndarray((dim, dim), dtype=np.complex128)) – The unitary matrix, to be square complex np.ndarray.
to_basis (MatrixBasis) – The matrix basis for representing the HS matrix
- Returns
The HS matrix of the gate corresponding to the unitary matrix, to be real.
- Return type
np.ndarray((dim^2, dim^2), dtype=np.float64)
- calc_hamiltonian_mat_from_gate_name_2qutrit_base_matrices(gate_name)[source]
Return a Hamiltonian matrix that corresponds to a given name of 2-qutirt gate whose Hamiltonian consists of base matrices.
- Parameters
gate_name (str) – Ex. 01xi90, 12z01y180
- Returns
A Hamiltonian matrix on 2-qutrit system
- Return type
np.ndarray((9, 9), dtype=np.complex128)
- calc_hamiltonian_mat_from_gate_name_2qutrit_single_base_matrix(gate_name)[source]
Return a Hamiltonian matrix for a given name of gate on 2-qutrit system whose Hamiltonian consists of single base matrix.
- Parameters
gate_name (str) –
- Returns
- Return type
np.ndarray(shape=(9,9), dtype=np.complex128)
- calc_levels_axis_angle_from_gate_name_1qutrit_single_gellmann(gate_name)[source]
return dictionary object containing three information for specifying a 1-qutrit Gell-Mann gate.
- Parameters
gate_name (str) – A name of gate, e.g., “12x90”.
- Returns
Example: {“levels”: “12”, “axis”: “x”, “angle”: “90”}
- Return type
Dict[str, str]
- calc_pauli_symbol_from_decimal_number(decimal_number, num_qubit)[source]
Return the Pauli symbol corresponding to a given decimal number and number of qubit.
- Parameters
decimal_number (int) –
num_qubit (int) –
- Returns
str
- Return type
a Pauli symbol
- calc_pauli_symbol_from_quadrant(quadrant)[source]
Return the Pauli symbol from a given quadtant.
- Parameters
quadrant (str) – Ex. “0”, “1”, “23”, “123”.
- Returns
str
- Return type
Ex. i, x, yz, xyz.
- calc_quadrant_from_decimal_number(value)[source]
Return a quadrant (4-ary) from a given decimal number.
- Parameters
value (int) – a decimal number
- Returns
str
- Return type
a quadrant
- calc_quadrant_from_pauli_symbol(symbol)[source]
Return the quadrant corresponding to a given pauli symbol.
- Parameters
symbol (str) – Ex. i, x, yz, xyz.
- Returns
str
- Return type
Ex. “0”, “1”, “23”, “123”
- calc_unitary_mat_from_hamiltonian_mat(h)[source]
return the unitary matrix for a given Hamiltonian matrix.
- Parameters
h (np.ndarray((dim, dim), dtype=np.complex128)) – Hamiltonian matrix
- Returns
- Return type
np.ndarray((dim dim), dtype=np.complex128), U = expm-(1j * h)
- convert_1qubit_pauli_index_to_pauli_symbol(index)[source]
- Parameters
index (Union[int, str]) –
- Return type
str
- convert_1qubit_pauli_symbol_to_pauli_index(symbol, mode)[source]
- Parameters
symbol (str) –
mode (str) –
- Return type
Union[int, str]
- convert_1qubit_pauli_symbol_to_pauli_index_int(symbol)[source]
- Parameters
symbol (str) –
- Return type
int
- convert_1qubit_pauli_symbol_to_pauli_index_str(symbol)[source]
- Parameters
symbol (str) –
- Return type
str
- convert_pauli_indices_to_pauli_symbol(indices)[source]
- Parameters
indices (List[int]) –
- Return type
str
- convert_pauli_symbol_to_pauli_indices(symbol)[source]
- Parameters
symbol (str) –
- Return type
List[int]
- generate_gate_1qutrit_single_gellmann(c_sys, gate_name, is_physicality_required=True)[source]
return the Gate for the gate.
- Parameters
gate_name (str) –
is_physicality_required (bool) –
- Return type
- generate_gate_1qutrit_single_gellmann_hamiltonian_mat(gate_name)[source]
return a 1-qutrit Hamiltonian matrix for the gate name.
- Parameters
gate_name (str) –
- Return type
numpy.ndarray
- generate_gate_1qutrit_single_gellmann_mat(gate_name)[source]
return the HS matrix for the gate.
- Parameters
gate_name (str) –
- Return type
numpy.ndarray
- generate_gate_1qutrit_single_gellmann_unitary_mat(gate_name)[source]
return the unitary matrix for the gate.
- Parameters
gate_name (str) –
- Return type
numpy.ndarray
- generate_gate_2qutrit_hamiltonian_mat_from_gate_name(gate_name, ids=None)[source]
Return a Hamiltonian of a 2-qutrit gate for a given gate name.
- Parameters
gate_name (str) –
ids (List[int] = None, Optional) – a list of elemental system ids, which specifies their roles such as control or target.
- Returns
- Return type
np.ndarray(shape=(9, 9), dtype=np.complex128)
- generate_gate_cx(c_sys, ids, is_physicality_required=True)[source]
Return the Gate class for the Control-X (CX) gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
ids (List[int]) – ids[0] for control system index ids[1] for target system index
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Control-X (CX) gate on the composite system.
- Return type
- generate_gate_cx_mat(ids)[source]
Return the Hilbert-Schmidt representation matrix for a Control-X (CX) gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 16 times 16 real matrix.
- Parameters
ids (List[int]) – ids[0] for the control system id, ids[1] for the target system id.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_cx_unitary_mat(ids)[source]
Return the unitary matrix for a Control-X (CX) gate.
The result is the 4 times 4 complex matrix.
- Parameters
ids (List[int]) – ids[0] for control system id, and ids[1] for target system id.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_cz(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Control-Z (CZ) gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Control-Z (CZ) gate on the composite system.
- Return type
- generate_gate_cz_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Control-Z (CZ) gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 16 times 16 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_cz_unitary_mat()[source]
Return the unitary matrix for a Control-Z (CZ) gate.
The result is the 4 times 4 complex matrix.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_fredkin_hamiltonian_mat(ids)[source]
Return the Hamiltonian matrix of the Fredkin gate (Controlled-SWAP).
\(H = \frac{\pi}{8} (-III + IXX + IYY + IZZ + ZII - ZXX - ZYY - ZZZ)\)
- Parameters
ids (List[int]) – ids[0] is for control, and ids[1] and ids[2] are for target.
- Returns
Hamiltonian matrix
- Return type
np.ndarray((8 8), dtype=np.complex128)
- generate_gate_from_gate_name(gate_name, c_sys, ids=None, is_physicality_required=True)[source]
returns gate class.
- Parameters
gate_name (str) – name of gate
c_sys (CompositeSystem) –
ids (List[int] (optional)) – list of ids for elemental systems
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The gate class for the input
- Return type
- generate_gate_hadamard(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Hadamard (H) gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Hadamard (H) gate on the composite system.
- Return type
- generate_gate_hadamard_mat()[source]
Return the Hilbert-Schmidt representation matrix for an Hadamard (H) gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_hadamard_unitary_mat()[source]
Return the unitary matrix for an Hadamard (H) gate.
The result is the 2 times 2 complex matrix, H.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_identity(c_sys, is_physicality_required=True)[source]
Return the Gate class for the identity gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the identity gate on the composite system.
- Return type
- generate_gate_identity_mat(dim)[source]
Return the Hilbert-Schmidt representation matrix for an Identity gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is the dim^2 times dim^2 real identity matrix.
- Parameters
dim (int) – The dimension of the quantum system on which the gate acts.
- Returns
The real Hilbert-Schmidt representation matrix for the gate. It is the identity matrix in this case.
- Return type
np.ndarray
- generate_gate_identity_unitary_mat(dim)[source]
Return the unitary matrix for an identity gate.
The result is the dim times dim complex identity matrix.
- Parameters
dim (int) – The dimension of the quantum system on which the gate acts.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_mat_from_gate_name(gate_name, dims=None, ids=None)[source]
returns the Hilbert-Schmidt representation matrix of a gate.
- Parameters
gate_name (str) – name of gate
dims (List[int]) – list of dimentions of elemental systems that the gate acts on.
ids (List[int] (optional)) – list of ids for elemental systems
- Returns
The HS matrix of the gate, to be real.
- Return type
np.ndarray
- generate_gate_object_from_gate_name_object_name(gate_name, object_name, dims=None, ids=None, c_sys=None, is_physicality_required=True)[source]
- Parameters
gate_name (str) –
object_name (str) –
dims (Optional[List[int]]) –
ids (Optional[List[int]]) –
c_sys (Optional[quara.objects.composite_system.CompositeSystem]) –
is_physicality_required (bool) –
- Return type
Union[numpy.ndarray, quara.objects.gate.Gate]
- generate_gate_phase(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Phase (S) gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Phase (S) gate on the composite system.
- Return type
- generate_gate_phase_daggered(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Phase daggered (S^dagger) gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Phase daggered (S^dagger) gate on the composite system.
- Return type
- generate_gate_phase_daggered_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Phase daggerd (S^dagger) gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_phase_daggered_unitary_mat()[source]
Return the unitary matrix for a Phase daggerd (S^dagger) gate.
The result is the 2 times 2 complex matrix, S^dagger.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_phase_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Phase (S) gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_phase_unitary_mat()[source]
Return the unitary matrix for a Phase (S) gate.
The result is the 2 times 2 complex matrix, S.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_piover8(c_sys, is_physicality_required=True)[source]
Return the Gate class for the pi/8 (T) gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the pi/8 (T) gate on the composite system.
- Return type
- generate_gate_piover8_daggered(c_sys, is_physicality_required=True)[source]
Return the Gate class for the pi/8 daggered (T^dagger) gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the pi/8 daggered (T^dagger) gate on the composite system.
- Return type
- generate_gate_piover8_daggered_mat()[source]
Return the Hilbert-Schmidt representation matrix for a pi/8 daggerd (T^dagger) gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_piover8_daggered_unitary_mat()[source]
Return the unitary matrix for a pi/8 daggerd (T^dagger) gate.
The result is the 2 times 2 complex matrix, T^dagger.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_piover8_mat()[source]
Return the Hilbert-Schmidt representation matrix for a pi/8 (T) gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_piover8_unitary_mat()[source]
Return the unitary matrix for a pi/8 (T) gate.
The result is the 2 times 2 complex matrix, T.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_swap(c_sys, is_physicality_required=True)[source]
Return the Gate class for the SWAP gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the SWAP gate on the composite system.
- Return type
- generate_gate_swap_mat()[source]
Return the Hilbert-Schmidt representation matrix for a SWAP gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 16 times 16 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_swap_unitary_mat()[source]
Return the unitary matrix for a SWAP gate.
The result is the 4 times 4 complex matrix.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_toffoli_hamiltonian_mat(ids)[source]
Return the Hamiltonian matrix of the Toffoli gate (Controlled-Controlled-NOT).
\(H = \frac{\pi}{8} (-III + IIX + IZI - IZX + ZII - ZIX - ZZI + ZZX)\)
- Parameters
ids (List[int]) – ids[0] and ids[1] are for control, and ids[2] is for target.
- Returns
Hamiltonian matrix
- Return type
np.ndarray((8 8), dtype=np.complex128)
- generate_gate_x(c_sys, is_physicality_required=True)[source]
Return the Gate class for the X gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the X gate on the composite system.
- Return type
- generate_gate_x180(c_sys, is_physicality_required=True)[source]
Return the Gate class for the X180 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the identity gate on the composite system.
- Return type
- generate_gate_x180_mat()[source]
Return the Hilbert-Schmidt representation matrix for an X180 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_x180_unitary_mat()[source]
Return the unitary matrix for an X180 gate.
The result is the 2 times 2 complex matrix, -i X.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_x90(c_sys, is_physicality_required=True)[source]
Return the Gate class for the X90 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the X90 gate on the composite system.
- Return type
- generate_gate_x90_mat()[source]
Return the Hilbert-Schmidt representation matrix for an X90 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_x90_unitary_mat()[source]
Return the unitary matrix for an X90 gate.
The result is the 2 times 2 complex matrix.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_x_mat()[source]
Return the Hilbert-Schmidt representation matrix for an X gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_x_unitary_mat()[source]
Return the unitary matrix for an X gate.
The result is the 2 times 2 complex matrix, X.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_y(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Y gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Y gate on the composite system.
- Return type
- generate_gate_y180(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Y180 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Y180 gate on the composite system.
- Return type
- generate_gate_y180_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Y180 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_y180_unitary_mat()[source]
Return the unitary matrix for a Y180 gate.
The result is the 2 times 2 complex matrix, -i Y.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_y90(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Y90 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Y90 gate on the composite system.
- Return type
- generate_gate_y90_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Y90 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_y90_unitary_mat()[source]
Return the unitary matrix for an Y90 gate.
The result is a 2 times 2 complex matrix.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_y_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Y gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_y_unitary_mat()[source]
Return the unitary matrix for a Y gate.
The result is the 2 times 2 complex matrix, Y.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_z(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Z gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Z gate on the composite system.
- Return type
- generate_gate_z180(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Z180 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Z180 gate on the composite system.
- Return type
- generate_gate_z180_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Z180 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_z180_unitary_mat()[source]
Return the unitary matrix for a Z180 gate.
The result is the 2 times 2 complex matrix, -i Z.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_z90(c_sys, is_physicality_required=True)[source]
Return the Gate class for the Z90 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the Z90 gate on the composite system.
- Return type
- generate_gate_z90_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Z90 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_z90_unitary_mat()[source]
Return the unitary matrix for a Z90 gate.
The result is a 2 times 2 complex matrix.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_z_mat()[source]
Return the Hilbert-Schmidt representation matrix for a Z gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 4 times 4 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_z_unitary_mat()[source]
Return the unitary matrix for a Z gate.
The result is the 2 times 2 complex matrix, Z.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_zx90(c_sys, ids, is_physicality_required=True)[source]
Return the Gate class for the ZX90 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
ids (List[int]) – ids[0] for control system index ids[1] for target system index
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the ZX90 gate on the composite system.
- Return type
- generate_gate_zx90_mat(ids)[source]
Return the Hilbert-Schmidt representation matrix for a ZX90 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 16 times 16 real matrix.
- Parameters
ids (List[int]) – ids[0] for the control system id, ids[1] for the target system id.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_zx90_unitary_mat(ids)[source]
Return the unitary matrix for a ZX90 gate.
The result is the 4 times 4 complex matrix.
- Parameters
ids (List[int]) – ids[0] for control system id, and ids[1] for target system id.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_gate_zz90(c_sys, is_physicality_required=True)[source]
Return the Gate class for the ZZ90 gate on the composite system.
- Parameters
c_sys (CompositeSystem) –
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The Gate class for the ZZ90 gate on the composite system.
- Return type
- generate_gate_zz90_mat()[source]
Return the Hilbert-Schmidt representation matrix for a ZZ90 gate with respect to the orthonormal Hermitian matrix basis with the normalized identity matrix as the 0th element.
The result is a 16 times 16 real matrix.
- Returns
The real Hilbert-Schmidt representation matrix for the gate.
- Return type
np.ndarray
- generate_gate_zz90_unitary_mat()[source]
Return the unitary matrix for a ZZ90 gate.
The result is the 4 times 4 complex matrix.
- Returns
The unitary matrix, which is a complex matrix.
- Return type
np.ndarray
- generate_unitary_mat_from_gate_name(gate_name, dims=None, ids=None)[source]
returns the unitary matrix of a gate.
- Parameters
gate_name (str) – name of gate
dims (List[int]) – list of dimentions of elemental systems that the gate acts on.
ids (List[int] (optional)) – list of ids for elemental systems
- Returns
The unitary matrix of the gate, to be complex.
- Return type
np.ndarray
- get_base_matrices_1qutrit()[source]
Return the dictionary object containing all base matrices for 1-qutrit Hamiltonian.
- Returns
The dictionary. The first string of the Tuple is for the levels, “01”, “12”, or “02”. The second string of the Tuple is for the axis, “x”, “y”, or “z”. For example, dict[(“12”, “x”)] is the base matrix for the x-axis w.r.t. the levels 1 and 2.
- Return type
Dict[Tuple[str, str], np.ndarray]
- get_base_matrix_names_1qutrit()[source]
Return a list of base matrix names for 1-qutrit system.
- Return type
List[str]
- get_base_matrix_names_2qutrit()[source]
Return a list of base matrix names for 2-qutrit system.
- Return type
List[str]
- get_gate_names_1qubit()[source]
Return the list of valid gate names of 1-qubit gates.
- Return type
List[str]
- get_gate_names_1qutrit()[source]
return the list of valid (implemented) gate names of 1-qutrit gates.
- Return type
List[str]
- get_gate_names_1qutrit_single_gellmann()[source]
return the list of valid (implemented) gate names of 1-qutrit single Gell-Mann gates.
- Return type
List[str]
- get_gate_names_2qubit()[source]
Return the list of valid gate names of 2-qubit gates.
- Return type
List[str]
- get_gate_names_2qubit_asymmetric()[source]
Return the list of valid gate names of 2-qubit gates that are asymmetric with respect to ids of elemental systems.
- Return type
List[str]
- get_gate_names_2qutrit()[source]
return the list of valid (implemented) gate names of 2-qutrit gates.
- Return type
List[str]
- get_gate_names_2qutrit_base_matrices()[source]
return the list of valid (implemented) gate names of 2-qutrit gates.
- Return type
List[str]
- get_gate_names_2qutrit_single_base_matrix()[source]
Return a list of gate names on 2-qutirt system whose Hamiltonian consists of single base matrix.
- Return type
List[str]
- get_gate_names_2qutrit_two_base_matrices()[source]
Return a list of gate names on 2-qutrit system whose Hamiltonian consists of two base matrices.
- Return type
List[str]
- get_gate_names_3qubit()[source]
Return the list of valid gate names of typical 3-qubit gates.
- Return type
List[str]
- get_gate_names_3qubit_asymmetric()[source]
Return the list of valid gate names of typical 3-qubit gates that are asymmetric with respect to ids of elemental systems.
- Return type
List[str]
- get_permutation_matrix_from_ascending_order(ids)[source]
Return a permutation matrix that convert soarted(ids) to ids.
- Parameters
ids (List[int]) – A list of integers, to have no duplication.
- Returns
A permutation matrix that convert the sorted list in the ascending order, sorted(ids), to the original list, ids.
- Return type
np.ndarray
- permute_pauli_symbol(symbol, ids)[source]
- Parameters
symbol (str) –
ids (List[int]) –
- Return type
str
- split_gate_name_2qutrit_base_matrices(gate_name)[source]
Return a list of gate names that are elements of a given gate name.
Ex. “01x02z90_12yi180” -> [“01x02z90”, “12yi180”]
- Parameters
gate_name (str) –
- Return type
List[str]
- split_gate_name_2qutrit_single_base_matrix_into_base_matrix_names_angle(gate_name)[source]
Return base matrix names and angle for a given 2-qutrit single base matrix name.
- Parameters
gate_names (str) – Ex. “i01x90”, “12yi180”, “02z12y90”
gate_name (str) –
- Returns
key = “base0”, “base1”, “angle”.
Ex.
{‘base0’: ‘i’, ‘base1’: ‘01x’, ‘angle’:’90’}
{‘base0’: ‘12y’, ‘base1’: ‘i’, ‘angle’:’180’}
{‘base0’: ‘02z’, ‘base1’: ‘12y’, ‘angle’:’90’}
- Return type
Dict[str, str]