This is an automated email from the ASF dual-hosted git repository.

guanmingchiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git


The following commit(s) were added to refs/heads/main by this push:
     new cb566c919 MAHOUT-607: Add Documents for CSWAP Gate and U Gate (#630)
cb566c919 is described below

commit cb566c919b503b7bd52d973bcd4895f5d7a9804d
Author: GUAN-HAO HUANG <[email protected]>
AuthorDate: Sun Nov 16 01:16:15 2025 +0800

    MAHOUT-607: Add Documents for CSWAP Gate and U Gate (#630)
    
    * Add Documents for CSWAP Gate and U Gate
    
    * Update docs/basic_gates.md
    
    Co-authored-by: Copilot <[email protected]>
    
    ---------
    
    Co-authored-by: rich <[email protected]>
    Co-authored-by: Copilot <[email protected]>
---
 docs/basic_gates.md | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/docs/basic_gates.md b/docs/basic_gates.md
index 32f730d87..6fe2533f0 100644
--- a/docs/basic_gates.md
+++ b/docs/basic_gates.md
@@ -46,10 +46,55 @@ The T-Gate applies a **π/4 phase shift** to the qubit. It 
is essential for quan
 \[ T|0⟩ = |0⟩ \]
 \[ T|1⟩ = e^{i\pi/4} |1⟩ \]
 
+## CSWAP Gate (Controlled-SWAP / Fredkin Gate)
+The CSWAP gate, also known as the **Fredkin gate**, is a three-qubit gate that 
conditionally swaps the states of two target qubits based on the state of a 
control qubit. If the control qubit is in the |1⟩ state, it swaps the states of 
the two target qubits; otherwise, it leaves them unchanged.
+
+### Mathematical Definition
+
+The CSWAP gate acts on three qubits: a control qubit |c⟩ and two target qubits 
|t₁⟩ and |t₂⟩. The operation is:
+
+\[ \text{CSWAP}|c\rangle|t_1\rangle|t_2\rangle = \begin{cases} 
|c\rangle|t_1\rangle|t_2\rangle & \text{if } c = 0 \\ 
|c\rangle|t_2\rangle|t_1\rangle & \text{if } c = 1 \end{cases} \]
+
+In matrix form (for the 8-dimensional space of three qubits), the CSWAP gate 
is:
+
+\[ \text{CSWAP} = \begin{pmatrix} 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{pmatrix} \]
+
+The CSWAP gate is fundamental in quantum algorithms such as the swap test, 
quantum error correction, and quantum state comparison. The CSWAP gate is 
reversible and preserves the number of |1⟩ states in the system (conserves the 
Hamming weight).
+
+## U Gate (Universal Single-Qubit Gate)
+The U gate is a **universal single-qubit gate** parameterized by three angles 
(θ, φ, λ) that can represent any single-qubit unitary operation. It provides a 
complete parameterization of single-qubit rotations and is essential for 
implementing arbitrary quantum operations.
+
+### Mathematical Definition
+
+The U gate matrix representation is:
+
+\[ U(\theta, \phi, \lambda) = \begin{pmatrix} \cos(\theta/2) & 
-e^{i\lambda}\sin(\theta/2) \\ e^{i\phi}\sin(\theta/2) & 
e^{i(\phi+\lambda)}\cos(\theta/2) \end{pmatrix} \]
+
+The U gate can be decomposed into rotations around the Z, Y, and Z axes:
+
+\[ U(\theta, \phi, \lambda) = R_z(\phi) \cdot R_y(\theta) \cdot R_z(\lambda) \]
+
+This decomposition shows that the U gate applies:
+1. A rotation by λ around the Z-axis
+2. A rotation by θ around the Y-axis
+3. A rotation by φ around the Z-axis
+
+### Special Cases
+
+- **Identity**: U(0, 0, 0) = I
+- **Pauli X**: U(π, 0, π) = X
+- **Pauli Y**: U(π, π/2, π/2) = Y
+- **Pauli Z**: U(0, 0, π) = Z
+- **Hadamard**: U(π/2, 0, π) = H
+
+This gate is particularly useful in parameterized quantum circuits and 
variational quantum algorithms where you need to optimize over all possible 
single-qubit operations.
+
 # **Updates**
 - **Acknowledged support for Cirq & Braket** (New Addition)
 - **Removed Pauli X Gate** (Merged into NOT Gate)
 - **Added T-Gate** (New Addition)
+- **Added CSWAP Gate** (New Addition)
+- **Added U Gate** (New Addition)
 - **Fixed typos**
 
 These quantum gates are fundamental building blocks in quantum computing, 
enabling the manipulation and transformation of qubit states to perform various 
quantum algorithms and computations.

Reply via email to