UnitaryDecomposition
QuICT.qcda.synthesis.unitary_decomposition.UnitaryDecomposition ¶
UnitaryDecomposition(method: str = 'uniformly_rotation', include_phase_gate: bool = False, recursive_basis: int = 2, ancilla: int = 0, opt: bool = False)
Bases: object
Transform a general unitary matrix into CX gates and single qubit gates.
References
[1] Synthesis of Quantum Logic Circuits
https://arxiv.org/abs/quant-ph/0406176
[2] Constructive quantum Shannon decomposition from Cartan involutions
https://arxiv.org/abs/0806.4015
[3] Minimal Universal Two-qubit Quantum Circuits
https://arxiv.org/abs/quant-ph/0308033
[4] Optimal quantum circuits for general two-qubit gates
https://arxiv.org/abs/quant-ph/0308006
Examples:
1.use the method of uniformly_rotation by default
>>> from QuICT.qcda.synthesis import UnitaryDecomposition
>>> UD = UnitaryDecomposition()
>>> gates, _ = UD.execute(mat)
2.use the method of diagonal_gate
>>> from QuICT.qcda.synthesis import UnitaryDecomposition
>>> UD = UnitaryDecomposition(method='diagonal_gate')
>>> gates, _ = UD.execute(mat)
Parameters:
-
method(str, default:'uniformly_rotation') –chosen method in ['uniformly_rotation', 'diagonal_gate']
-
include_phase_gate(bool, default:False) –Whether to include a phase gate to keep synthesized gate matrix the same as input. If set False, the output gates might have a matrix which has a factor shift to input: np.allclose(
* factor, ). -
recursive_basis(int, default:2) –Terminate recursion at which level. It could be set as 1 or 2, which would stop recursion when matrix is 2 or 4, respectively. When set as 2, the final step is done by KAK decomposition. Correctness of this algorithm is never influenced by recursive_basis.
-
ancilla(int, default:0) –the number of ancillary qubits when the method is 'diagonal_gate'
-
opt(bool, default:False) –the switch of cnot optimizer when the method is 'diagonal_gate'
Source code in QuICT/qcda/synthesis/unitary_decomposition/unitary_decomposition.py
execute ¶
Parameters:
-
mat(ndarray) –Unitary matrix.
Returns:
-
Union[Tuple[CompositeGate, None], Tuple[CompositeGate, complex]]–Union[Tuple[CompositeGate, None], Tuple[CompositeGate, complex]]: If self.include_phase_gate==False,
-
Union[Tuple[CompositeGate, None], Tuple[CompositeGate, complex]]–this function returns synthesized gates and a shift factor. Otherwise a tuple like (
, None) -
Union[Tuple[CompositeGate, None], Tuple[CompositeGate, complex]]–is returned.