ControlledUnitaryDecomposition
QuICT.qcda.synthesis.unitary_decomposition.ControlledUnitaryDecomposition ¶
ControlledUnitaryDecomposition(include_phase_gate: bool = True, recursive_basis: int = 2, method: str = 'uniformly_rotation', ancilla: int = 0, opt: bool = False)
Bases: object
Parameters:
-
include_phase_gate(bool, default:True) –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.
-
method(str, default:'uniformly_rotation') –chosen method in ['uniformly_rotation', 'diagonal_gate']
-
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/controlled_unitary.py
execute ¶
execute(u1: ndarray, u2: ndarray) -> Union[Tuple[CompositeGate, None], Tuple[CompositeGate, complex]]
Transform a controlled-unitary matrix into CX gates and single qubit gates. A controlled-unitary is a block-diagonal unitary. Parameter u1 and u2 are the block diagonals.
Parameters:
-
u1(ndarray) –Upper-left block diagonal.
-
u2(ndarray) –bottom-right block diagonal.
Returns:
-
Union[Tuple[CompositeGate, None], Tuple[CompositeGate, complex]]–Union[Tuple[CompositeGate, None], Tuple[CompositeGate, complex]]: If self.inlclude_phase_gate==False, this function returns synthesized gates and a shift factor. Otherwise a tuple like (
, None) is returned.
Source code in QuICT/qcda/synthesis/unitary_decomposition/controlled_unitary.py
inner_cutrans_build_gate ¶
inner_cutrans_build_gate(u1: ndarray, u2: ndarray, recursive_basis: int = 2, keep_left_diagonal: bool = False, method: str = 'uniformly_rotation') -> Tuple[CompositeGate, complex]
Build gates from parameterized model without mapping
Returns:
-
Tuple[CompositeGate, complex]–Tuple[CompositeGate, complex]: Synthesized gates and factor shift.