quairkit.database.matrix¶
Gate matrices.
- quairkit.database.matrix.grover_matrix(oracle)¶
Construct the Grover operator based on
oracle
.- Parameters:¶
- oracle : Tensor¶
the input oracle \(A\) to be rotated.
- Returns:¶
Grover operator in form
- Return type:¶
Tensor
\[G = A (2 |0^n \rangle\langle 0^n| - I^n) A^\dagger \cdot (I - 2|1 \rangle\langle 1|) \otimes I^{n-1}\]
-
quairkit.database.matrix.qft_matrix(num_qubits, dtype=
torch.complex64
)¶ Construct the quantum fourier transpose (QFT) gate.
- Parameters:¶
- Returns:¶
a gate in below matrix form, here \(\omega_N = \text{exp}(\frac{2 \pi i}{N})\)
- Return type:¶
Tensor
\[\begin{split}\begin{align} QFT = \frac{1}{\sqrt{N}} \begin{bmatrix} 1 & 1 & .. & 1 \\ 1 & \omega_N & .. & \omega_N^{N-1} \\ .. & .. & .. & .. \\ 1 & \omega_N^{N-1} & .. & \omega_N^{(N-1)^2} \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.h(dtype=
None
)¶ Generate the matrix
\[\begin{split}H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1&1\\ 1&-1 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.s(dtype=
None
)¶ Generate the matrix
\[\begin{split}S = \begin{bmatrix} 1&0\\ 0&i \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.sdg(dtype=
None
)¶ Generate the matrix
\[\begin{split}S^\dagger = \begin{bmatrix} 1&0\\ 0&-i \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.t(dtype=
None
)¶ Generate the matrix
\[\begin{split}T = \begin{bmatrix} 1&0\\ 0&e^\frac{i\pi}{4} \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.tdg(dtype=
None
)¶ Generate the matrix
\[\begin{split}T^\dagger = \begin{bmatrix} 1&0\\ 0&e^{-\frac{i\pi}{4}} \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.eye(dtype=
None
)¶ Generate the matrix
\[\begin{split}I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.x(dtype=
None
)¶ Generate the matrix
\[\begin{split}X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.y(dtype=
None
)¶ Generate the matrix
\[\begin{split}Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.z(dtype=
None
)¶ Generate the matrix
\[\begin{split}Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\end{split}\]
- quairkit.database.matrix.p(theta)¶
Generate the matrix
\[\begin{split}P(\theta) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.rx(theta)¶
Generate the matrix
\[\begin{split}R_X(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.ry(theta)¶
Generate the matrix
\[\begin{split}R_Y(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.rz(theta)¶
Generate the matrix
\[\begin{split}R_Z(\theta) = \begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.u3(theta)¶
Generate the matrix
\[\begin{split}\begin{align} U_3(\theta, \phi, \lambda) = \begin{bmatrix} \cos\frac\theta2&-e^{i\lambda}\sin\frac\theta2\\ e^{i\phi}\sin\frac\theta2&e^{i(\phi+\lambda)}\cos\frac\theta2 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cnot(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CNOT} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes X\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cy(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CY} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes Y\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cz(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CZ} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes Z\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.swap(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{SWAP} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.cp(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CP}(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\theta} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.crx(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CR_X} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes R_X\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ 0 & 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.cry(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CR_Y} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes R_Y\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ 0 & 0 & \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.crz(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CR_Z} &= |0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes R_Z\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{i\frac{\theta}{2}} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.cu(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CU} &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{i\gamma}\cos\frac\theta2 &-e^{i(\lambda+\gamma)}\sin\frac\theta2 \\ 0 & 0 & e^{i(\phi+\gamma)}\sin\frac\theta2&e^{i(\phi+\lambda+\gamma)}\cos\frac\theta2 \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.rxx(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{R_{XX}}(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & 0 & 0 & -i\sin\frac{\theta}{2} \\ 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} & 0 \\ 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} & 0 \\ -i\sin\frac{\theta}{2} & 0 & 0 & \cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.ryy(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{R_{YY}}(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & 0 & 0 & i\sin\frac{\theta}{2} \\ 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} & 0 \\ 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} & 0 \\ i\sin\frac{\theta}{2} & 0 & 0 & cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.rzz(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{R_{ZZ}}(\theta) = \begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i\frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{-i\frac{\theta}{2}} \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.ms(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{MS} = \mathit{R_{XX}}(-\frac{\pi}{2}) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 0 & 0 & i \\ 0 & 1 & i & 0 \\ 0 & i & 1 & 0 \\ i & 0 & 0 & 1 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cswap(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CSWAP} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.toffoli(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{Toffoli} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.universal_qudit(theta, dimension)¶
Generalized GellMann matrix basis were used to construct the universal gate for qudits
References
[wolfram mathworld](https://mathworld.wolfram.com/GeneralizedGell-MannMatrix.html)
- quairkit.database.matrix.Uf(f, n)¶
Construct the unitary matrix maps \(|x\rangle|y\rangle\) to \(|x\rangle|y\oplus f(x)\rangle\) based on a boolean function \(f\).
\[U: U|x\rangle|y\rangle = |x\rangle|y\oplus f(x)\rangle\]
- quairkit.database.matrix.Of(f, n)¶
Construct the unitary matrix maps \(|x\rangle\) to \((-1)^{f(x)}|x\rangle\) based on a boolean function \(f\).
\[U: U|x\rangle = (-1)^{f(x)}|x\rangle\]
- quairkit.database.matrix.reduce_gate()¶
reduce(function, iterable[, initial]) -> value
Apply a function of two arguments cumulatively to the items of a sequence or iterable, from left to right, so as to reduce the iterable to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the iterable in the calculation, and serves as a default when the iterable is empty.
-
quairkit.database.matrix.h_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1&1\\ 1&-1 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.s_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}S = \begin{bmatrix} 1&0\\ 0&i \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.sdg_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}S^\dagger = \begin{bmatrix} 1&0\\ 0&-i \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.t_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}T = \begin{bmatrix} 1&0\\ 0&e^\frac{i\pi}{4} \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.tdg_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}T^\dagger = \begin{bmatrix} 1&0\\ 0&e^{-\frac{i\pi}{4}} \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.eye_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.x_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.y_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\end{split}\]
-
quairkit.database.matrix.z_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\end{split}\]
- quairkit.database.matrix.p_gate(theta)¶
Generate the matrix
\[\begin{split}P(\theta) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.rx_gate(theta)¶
Generate the matrix
\[\begin{split}R_X(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.ry_gate(theta)¶
Generate the matrix
\[\begin{split}R_Y(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.rz_gate(theta)¶
Generate the matrix
\[\begin{split}R_Z(\theta) = \begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{bmatrix}\end{split}\]
- quairkit.database.matrix.u3_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} U_3(\theta, \phi, \lambda) = \begin{bmatrix} \cos\frac\theta2&-e^{i\lambda}\sin\frac\theta2\\ e^{i\phi}\sin\frac\theta2&e^{i(\phi+\lambda)}\cos\frac\theta2 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cnot_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CNOT} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes X\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cy_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CY} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes Y\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cz_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CZ} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes Z\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.swap_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{SWAP} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.cp_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CP}(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\theta} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.crx_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CR_X} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes R_X\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ 0 & 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.cry_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CR_Y} &=|0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes R_Y\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ 0 & 0 & \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.crz_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CR_Z} &= |0\rangle \langle 0|\otimes I + |1 \rangle \langle 1|\otimes R_Z\\ &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{i\frac{\theta}{2}} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.cu_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{CU} &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{i\gamma}\cos\frac\theta2 &-e^{i(\lambda+\gamma)}\sin\frac\theta2 \\ 0 & 0 & e^{i(\phi+\gamma)}\sin\frac\theta2&e^{i(\phi+\lambda+\gamma)}\cos\frac\theta2 \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.rxx_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{R_{XX}}(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & 0 & 0 & -i\sin\frac{\theta}{2} \\ 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} & 0 \\ 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} & 0 \\ -i\sin\frac{\theta}{2} & 0 & 0 & \cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.ryy_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{R_{YY}}(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & 0 & 0 & i\sin\frac{\theta}{2} \\ 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} & 0 \\ 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} & 0 \\ i\sin\frac{\theta}{2} & 0 & 0 & cos\frac{\theta}{2} \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.rzz_gate(theta)¶
Generate the matrix
\[\begin{split}\begin{align} \mathit{R_{ZZ}}(\theta) = \begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i\frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{-i\frac{\theta}{2}} \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.ms_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{MS} = \mathit{R_{XX}}(-\frac{\pi}{2}) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 0 & 0 & i \\ 0 & 1 & i & 0 \\ 0 & i & 1 & 0 \\ i & 0 & 0 & 1 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.cswap_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{CSWAP} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} \end{align}\end{split}\]
-
quairkit.database.matrix.toffoli_gate(dtype=
None
)¶ Generate the matrix
\[\begin{split}\begin{align} \mathit{Toffoli} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix} \end{align}\end{split}\]
- quairkit.database.matrix.Uf_gate(f, n)¶
Construct the unitary matrix maps \(|x\rangle|y\rangle\) to \(|x\rangle|y\oplus f(x)\rangle\) based on a boolean function \(f\).
\[U: U|x\rangle|y\rangle = |x\rangle|y\oplus f(x)\rangle\]