givens_decomposition
givens_decomposition(unitary)
Decomposes a unitary matrix into Givens rotations and diagonal phases.
The unitary matrix, , can be decomposed into a diagonal matrix, , and sequence of Givens rotations, , acting on adjacent indices. This algorithm [1] requires at most such Givens rotations.
Each Givens rotation is defined by a 4-tuple, (c, s, i, j), with:
c: the real-valued cosines: the complex-valued sinei: the first row indexj: the second row index
which result in a matrix of the form:
Parameters
unitary – the unitary matrix, , to be decomposed.
Returns
A 2-tuple consisting of
- the sequence of Givens rotations represented as 4-tuples as explained above
- the vector of complex phases of the diagonal matrix,
The original unitary is recovered by processing the returned rotations in reverse order and right-multiplying the diagonal matrix by the element-wise complex conjugate of each rotation matrix (as defined above). That is, for returned rotations,
where denotes element-wise conjugation (not the conjugate transpose) and each acts only on rows/columns and of its rotation.
>>> import numpy as np
>>> from qiskit_fermions.linalg import givens_decomposition
>>> unitary = np.array([[0.6, 0.8j], [0.8, -0.6j]], dtype=complex)
>>> rotations, phases = givens_decomposition(unitary)
>>> reconstructed = np.diag(phases).astype(complex)
>>> for c, s, i, j in rotations[::-1]:
... givens_mat = np.eye(2, dtype=complex)
... givens_mat[np.ix_((i, j), (i, j))] = [[c, s], [-s.conjugate(), c]]
... reconstructed = reconstructed @ givens_mat.conj()
>>> bool(np.allclose(reconstructed, unitary))
True
[1]
W. R. Clements et al., Optimal design for universal multiport interferometers, Optica 3, 1460-1465 (2016), doi:10.1364/OPTICA.3.001460.