QuantumCircuit.squ¶

QuantumCircuit.squ(unitary_matrix, qubit, mode='ZYZ', up_to_diagonal=False, *, u=None)

Decompose an arbitrary 2*2 unitary into three rotation gates.

Note that the decomposition is up to a global phase shift. (This is a well known decomposition, which can be found for example in Nielsen and Chuang’s book “Quantum computation and quantum information”.)

Parameters
• unitary_matrix (ndarray) – 2*2 unitary (given as a (complex) ndarray).

• qubit (QuantumRegister | Qubit) – The qubit which the gate is acting on.

• mode (string) – determines the used decomposition by providing the rotation axes. The allowed modes are: “ZYZ” (default)

• up_to_diagonal (bool) – if set to True, the single-qubit unitary is decomposed up to a diagonal matrix, i.e. a unitary u’ is implemented such that there exists a 2*2 diagonal gate d with u = d.dot(u’)

• u (ndarray) – Deprecated, use unitary_matrix instead.

Returns

The single-qubit unitary instruction attached to the circuit.

Return type

InstructionSet

Raises

QiskitError – if the format is wrong; if the array u is not unitary