# How to define custom controlled unitaries in OPENQASM 2.0?

According to the OPENQASM 2.0 documentation, it's possible to define custom unitary gates using the format:

gate name(params) qargs
{
body
}


where the optional parameter list params is a comma-separated list of variable parameter names, and the argument list qargs is a comma-separated list of qubit arguments.

In my specific case, I'm trying to implement a single-qubit controlled unitary which will act on two qubits. So is there a way to define a custom controlled unitary gate in OPENQASM 2.0? It should work on the new IBM Quantum Experience Beta.

• How if given your unitary? As a matrix? A sequence of quantum gates? A quantum gate previously defined with the syntax you gave above? – Adrien Suau Jun 3 '19 at 16:59
• @Nelimee As a sequence of quantum gates acting on two qubits. I can write the two-qubit unitary in the syntax above I suppose, but I'm not sure how to implement the control by a third qubit. – Sanchayan Dutta Jun 3 '19 at 17:02