Unitary Function
Given a \(2^{n}\times2^{n}\) unitary matrix, the unitary-gate function constructs an equivalent unitary function that acts on \(n\) qubits accordingly. For \(n>2\), the synthesis process implementation is based on [1].
Function: unitary
Arguments:
-
elements: CArray[CArray[CReal]]
- A 2d array of complex numbers representing the unitary matrix. -
target: QArray[QBit]
- The quantum state to apply the unitary on. Should be of corresponding size.
Example
This example shows a \(2\)-qubit unitary function application in the formed \(4\)-dimensional space.
from classiq import Output, QArray, QBit, allocate, create_model, qfunc, unitary
UNITARY = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1j, 0], [0, 0, 0, 1j]]
@qfunc
def main(x: Output[QArray[QBit]]):
allocate(2, x)
unitary(UNITARY, x)
qmod = create_model(main)
from classiq import synthesize, write_qmod
write_qmod(qmod, "unitary")
qprog = synthesize(qmod)
References
[1] R. Iten et al, Quantum Circuits for Isometries, Phys. Rev. A 93 (2016). https://link.aps.org/doi/10.1103/PhysRevA.93.032318