Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
Given a 2n×2n2^{n}\times2^{n} unitary matrix, the unitary-gate function constructs an equivalent unitary function that acts on nn qubits accordingly. For n>2n>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 22-qubit unitary function application in the formed 44-dimensional space.
from classiq import *

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)

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