-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add quantum fourier transform example to playground
- Loading branch information
1 parent
686b18d
commit 4c0bc0b
Showing
1 changed file
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//init | ||
qubit x_1 = 0q; | ||
qubit x_2 = 1q; | ||
qubit x_3 = 1q; | ||
|
||
//QFT | ||
hadamard x_1; | ||
mcp x_1,x_2 by (3.14/2); | ||
mcp x_1,x_2 by (3.14/4); | ||
|
||
hadamard x_2; | ||
mcp x_2,x_3 by (3.14/2); | ||
|
||
hadamard x_3; | ||
|
||
swap x_3,x_1; | ||
|
||
|
||
//inverse | ||
|
||
hadamard x_1; | ||
mcp x_1,x_2 by (-3.14/2); | ||
mcp x_1,x_2 by (-3.14/4); | ||
|
||
hadamard x_2; | ||
mcp x_2,x_3 by (-3.14/2); | ||
|
||
hadamard x_3; | ||
swap x_3,x_1; | ||
|
||
//measure | ||
|
||
measure x_1; | ||
measure x_2; | ||
measure x_3; |