Skip to content

Commit

Permalink
[fix] two-qubit gates with qubit ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Mc-Zen committed Sep 2, 2024
1 parent e124160 commit 795b715
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/tequila-impl.typ
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
if type(control) == int { control = (control,) }
if type(target) == int { target = (target,) }

for c in control {
for t in target {
assert.ne(t, c, message: "Target and control qubit cannot be the same")
gates.push(bgate(c, start, nq: t - c + 1, end: end, t - c) )
}
for i in range(calc.max(control.len(), target.len())) {
let c = control.at(i, default: control.last())
let t = target.at(i, default: target.last())
assert.ne(t, c, message: "Target and control qubit cannot be the same")
gates.push(bgate(c, start, nq: t - c + 1, end: end, t - c) )

}
gates
}
Expand Down
3 changes: 2 additions & 1 deletion tests/tequila/basic/test.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#set page(width: auto, height: auto, margin: 0pt)
#import "/src/quill.typ" as quill: tequila as tq
#import "/src/quill.typ"
#import quill: tequila as tq

#quill.quantum-circuit(
..tq.build(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions tests/tequila/ranges-with-two-qubit-gates/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#set page(width: auto, height: auto, margin: 0pt)
#import "/src/quill.typ"
#import quill: tequila as tq

#quill.quantum-circuit(
..tq.build(
tq.cx((0, 1), (1, 2)),
tq.cx(0, (1,2)),
tq.cx((1, 2), 0),
)
)

0 comments on commit 795b715

Please sign in to comment.