Skip to content

Commit e2bd1ec

Browse files
committed
Update cmd
1 parent ecd1852 commit e2bd1ec

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

cmd/counting/main.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,13 @@ func main() {
7676
qsim.Swap(c...)
7777
qsim.InvQFT(c...)
7878

79-
// results
80-
N := 1 << len(r)
79+
// estimate
80+
N, Q := 1<<len(r), 1<<t
8181
for _, state := range q.Top(qsim.State(c, r, s, a), top) {
82-
phi := ldexp(state.Int()[0], -t) // phi = k / 2**t
82+
phi := float64(state.Int()[0]) / float64(Q) // phi = k / 2**t
8383
theta := 2 * math.Pi * phi // theta = 2*pi*phi
8484
M := float64(N) * math.Pow(math.Sin(theta/2), 2) // M = N*(sin(theta/2))**2
8585

8686
fmt.Printf("%v; phi=%.4f, theta=%.4f, M=%.4f, M'=%.4f\n", state, phi, theta, M, float64(N)-M)
8787
}
8888
}
89-
90-
func ldexp(a, b int) float64 {
91-
return math.Ldexp(float64(a), b)
92-
}

0 commit comments

Comments
 (0)