2
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ How if given your unitary? As a matrix? A sequence of quantum gates? A quantum gate previously defined with the syntax you gave above? $\endgroup$ Commented Jun 3, 2019 at 16:59
  • $\begingroup$ @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. $\endgroup$ Commented Jun 3, 2019 at 17:02

1 Answer 1

1
$\begingroup$

Unfortunately, I'm pretty sure that the functionality you desire does not exist. You'll need to do it by constructing the unitary yourself, for example via this method provided in the answer to another question.

For reference, the full specification for OpenQASM 2.0 can be found here.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.