Unverified Commit 23bb2584 authored by Mccaskey, Alex's avatar Mccaskey, Alex Committed by GitHub
Browse files

Merge pull request #90 from tnguyen-ornl/tnguyen/qfactor-example

Added qfactor synthesis example
parents db92f445 da430ddc
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,4 +30,4 @@ Employing the QCOR just-in-time (qjit) compilation features, we can wrap QCOR in

`vqe_ftqc.py` example demonstrating VQE algorithm using the ftqc runtime. 

`unitary.py` example demonstrating circuit synthesis language extension.
 No newline at end of file
`unitary.py`, `qcor_qsearch.py` and `qcor_qfactor.py`: examples demonstrating circuit synthesis language extension.
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
from qcor import *

@qjit
def ccnot(q : qreg):
    # create 111
    for i in range(q.size()):
        X(q[i])
    # decompose with qfactor        
    with decompose(q, qfactor) as ccnot:
        ccnot = np.eye(8)
        ccnot[6,6] = 0.0
        ccnot[7,7] = 0.0
        ccnot[6,7] = 1.0
        ccnot[7,6] = 1.0
    
    # CCNOT should produce 110 (lsb)
    for i in range(q.size()):
        Measure(q[i])

q = qalloc(3)
ccnot(q)
counts = q.counts()
print(counts)