Base Module API Reference
This page documents the base classes and functions in the skq.base
module. These components form the foundation of the SKQ framework.
Base Classes
skq.base.Operator
Bases: ndarray
Base class for Quantum Operators. Gates, density matrices, hamiltonians, etc. are all operators. The operator must be a 2D matrix. :param input_array: Input array to create the operator. Will be converted to a NumPy array.
Source code in src/skq/base.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
__call__(other)
Call the operator on a quantum state.
Source code in src/skq/base.py
135 136 137 |
|
commute(other)
Check if operator commute. U and V commute if UV = VU. :param other: Operator to check commutation with.
Source code in src/skq/base.py
102 103 104 105 106 107 108 109 |
|
conjugate_transpose()
Conjugate transpose (i.e. Hermitian adjoint or 'dagger operation') of the operator. 1. Transpose the matrix 2. Take the complex conjugate of each element (Flip the sign of the imaginary part)
Source code in src/skq/base.py
76 77 78 79 80 81 82 |
|
decodes(other)
Reverse quantum state
Source code in src/skq/base.py
26 27 28 |
|
eigenvalues()
Eigenvalues of the operator. Hermitian operators use eigvalsh for stable and faster computation.
Source code in src/skq/base.py
84 85 86 87 88 89 |
|
eigenvectors()
Eigenvectors of the operator. Hermitian operators use eigh for stable and faster computation.
Source code in src/skq/base.py
91 92 93 94 95 96 |
|
encodes(other)
Progress quantum state
Source code in src/skq/base.py
22 23 24 |
|
frobenius_norm()
Compute the Frobenius norm
Source code in src/skq/base.py
98 99 100 |
|
from_pennylane(pennylane_operator)
Convert a PennyLane Operation to scikit-q Operator. :param pennylane_gate: PennyLane Operation object. :return: scikit-q Operator
Source code in src/skq/base.py
127 128 129 130 131 132 133 |
|
from_qiskit(qiskit_operator)
Convert a Qiskit operator to scikit-q Operator. :param qiskit_operator: Qiskit Operator :return: scikit-q Operator object
Source code in src/skq/base.py
115 116 117 118 119 120 121 |
|
is_2d()
Operator is a 2D matrix.
Source code in src/skq/base.py
34 35 36 |
|
is_at_least_nxn(n)
Operator is at least an n x n matrix.
Source code in src/skq/base.py
38 39 40 41 |
|
is_equal(other)
Check if the operator is effectively equal to another operator.
Source code in src/skq/base.py
68 69 70 |
|
is_hermitian()
Check if the operator is Hermitian: U = U^dagger
Source code in src/skq/base.py
60 61 62 |
|
is_identity()
Check if the operator is the identity matrix.
Source code in src/skq/base.py
64 65 66 |
|
is_power_of_n_shape(n)
Operator shape is a power of n. Qubits: n=2, Qutrits: n=3, Ququarts: n=4, Qupents: n=5, etc. :param n: Number to check for power of n shape.
Source code in src/skq/base.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
is_square()
Operator is a square matrix.
Source code in src/skq/base.py
30 31 32 |
|
num_levels()
Number of rows. Used for checking valid shapes.
Source code in src/skq/base.py
72 73 74 |
|
to_pennylane()
Convert gate to a PennyLane gate object.
Source code in src/skq/base.py
123 124 125 |
|
to_qiskit()
Convert operator to a Qiskit.
Source code in src/skq/base.py
111 112 113 |
|
skq.base.HermitianOperator
Bases: Operator
Hermitian operator (observable) class. :param input_array: Input array to create the operator. Will be converted to a NumPy array.
Source code in src/skq/base.py
140 141 142 143 144 145 146 147 148 149 150 |
|