Skip to content

Commit dbc7607

Browse files
authored
Update counting
1 parent 8a570f5 commit dbc7607

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cmd/counting/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// The number of solutions `M` is 2.
1515
func controlledG(qsim *q.Q, r, s []q.Qubit, c, a q.Qubit) {
1616
oracle(qsim, r, s, c, a)
17-
diffuser(qsim, r, a)
17+
diffuser(qsim, r, c, a)
1818
}
1919

2020
func oracle(qsim *q.Q, r, s []q.Qubit, c, a q.Qubit) {
@@ -29,7 +29,7 @@ func oracle(qsim *q.Q, r, s []q.Qubit, c, a q.Qubit) {
2929
xor(r[1], r[3], s[3]) // b != d
3030

3131
// apply Z if all a are 1
32-
qsim.ControlledZ([]q.Qubit{c, s[0], s[1], s[2], s[3]}, []q.Qubit{a})
32+
qsim.ControlledZ(append([]q.Qubit{c}, s...), []q.Qubit{a})
3333

3434
// uncompute
3535
xor(r[1], r[3], s[3])
@@ -38,10 +38,10 @@ func oracle(qsim *q.Q, r, s []q.Qubit, c, a q.Qubit) {
3838
xor(r[0], r[1], s[0])
3939
}
4040

41-
func diffuser(qsim *q.Q, r []q.Qubit, a q.Qubit) {
41+
func diffuser(qsim *q.Q, r []q.Qubit, c, a q.Qubit) {
4242
qsim.H(r...)
4343
qsim.X(r...)
44-
qsim.ControlledZ(r, []q.Qubit{a})
44+
qsim.ControlledZ(append([]q.Qubit{c}, r...), []q.Qubit{a})
4545
qsim.X(r...)
4646
qsim.H(r...)
4747
}

0 commit comments

Comments
 (0)