A cosine-sine factor, or CS matrix, is the middle matrix in a cosine-sine decomposition. For an n-qubit operation, it has the form CS = [[C, -S], [S, C]], where C and S are diagonal 2^(n−1) × 2^(n−1) matrices satisfying C² + S² = I. Each matching pair obeys cₖ² + sₖ² = 1, so the CS matrix describes a unitary transformation even though C and S individually need not be unitary. section 3.4 section 3.9 section 3.6.1
Implement a two-qubit CS unitary by converting its coefficient pairs into controlled rotations:
- Form M₀ = [[c₀, −s₀], [s₀, c₀]] and M₁ = [[c₁, −s₁], [s₁, c₁]]. section 3.6.1
- Apply controlled M₁ with the least significant qubit as control. section 3.6.1 section 3.6.2
- Apply controlled-on-zero M₀ using the same control; the two gates act independently, so their order does not matter. section 3.6.1
Two-qubit implementation
Qiskit accepts only the nonzero coefficients, constructs M₀ and M₁, and appends their controlled forms. Q# performs the same decomposition with Controlled and ApplyControlledOnInt; its least significant control is the register’s last qubit. Tests reconstruct the implemented matrix and are expected to pass. section 3.6.2 section 3.6.3
Figure 3.3 Cosine-sine decomposition for an example \(4 \times 4\) matrix. This matrix is represented as a product of three matrices: a block-diagonal matrix defined by \(2 \times 2\) matrices \(A_l\) and \(B_l\), a block matrix of special shape called CS matrix defined by \(2 \times 2\) diagonal matrices \(C\) and \(S\), and another block-diagonal matrix defined by \(2 \times 2\) matrices \(A_r\) and \(B_r\).
Inspect the factor’s position between block-diagonal matrices in a 4 × 4 cosine-sine decomposition. section 3.4
For arbitrary size, pair each diagonal entry cₖ, sₖ with a controlled single-qubit gate Mₖ. The n−1 control bits encode k in little-endian form, allowing the CS unitary to be assembled from multi-controlled gates and used as a building block for arbitrary real unitaries. section 3.9.1 section 3.10.2
