-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
183 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,42 @@ | ||
from qiskit import QuantumCircuit | ||
|
||
from qlasskit import Int4, qlassf | ||
from qlasskit import Qint4, qlassf | ||
|
||
|
||
@qlassf | ||
def f(n: Int4) -> bool: | ||
if n == 3: | ||
return True | ||
else: | ||
return False | ||
def f1(n: Qint4) -> bool: | ||
return n == 7 | ||
|
||
@qlassf | ||
def f2(n: Qint4, b: bool) -> bool: | ||
return n > 3 | ||
|
||
@qlassf | ||
def f3(a: bool, b: bool) -> bool: | ||
return a or b | ||
|
||
@qlassf | ||
def f_comp(n: Qint4) -> bool: | ||
return n > 3 or n == 7 | ||
|
||
|
||
print(f_comp.expressions) | ||
gate = f_comp.gate() | ||
qc = QuantumCircuit(gate.num_qubits) | ||
qc.barrier(label="f_comp") | ||
qc.append(gate, list(range(gate.num_qubits))) | ||
print(qc.decompose().draw('text')) | ||
|
||
|
||
|
||
qc = QuantumCircuit(f.num_qubits) | ||
qc.append(f.gate(), f.qubits(0)) | ||
gate1 = f1.gate() | ||
gate2 = f2.gate() | ||
gate3 = f3.gate() | ||
qc = QuantumCircuit(max(gate1.num_qubits, gate2.num_qubits) + gate3.num_qubits) | ||
qc.barrier(label="=") | ||
qc.append(gate1, [0, 1, 2, 3, 4, 5]) | ||
qc.barrier(label=">") | ||
qc.append(gate2, [0, 1, 2, 3, 6, 7, 8, 9]) | ||
qc.barrier(label="|") | ||
qc.append(gate3, [5, 9, 10, 11, 12]) | ||
print(qc.decompose().draw('text')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from qiskit import QuantumCircuit | ||
|
||
from qlasskit import Qint4, qlassf | ||
|
||
|
||
@qlassf | ||
def f1(n: Qint4) -> Qint4: | ||
return n + 1 | ||
|
||
@qlassf | ||
def f2(n: Qint4) -> Qint4: | ||
return n + 3 | ||
|
||
@qlassf | ||
def f_comp(n: Qint4) -> Qint4: | ||
return n + 1 + 3 | ||
|
||
|
||
print(f_comp.expressions) | ||
gate = f_comp.gate() | ||
qc = QuantumCircuit(gate.num_qubits) | ||
qc.append(gate, list(range(gate.num_qubits))) | ||
print(qc.decompose().draw('text')) | ||
|
||
|
||
|
||
gate1 = f1.gate() | ||
gate2 = f2.gate() | ||
qc = QuantumCircuit(max(gate1.num_qubits, gate2.num_qubits)) | ||
qc.append(gate1, list(range(gate1.num_qubits))) | ||
qc.append(gate2, list(range(gate2.num_qubits))) | ||
print(qc.decompose().draw('text')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters