aboutsummaryrefslogtreecommitdiff
path: root/hw9/YaoQuantumComputing.jl
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2024-05-07 07:00:43 -0400
committersotech117 <michael_foiani@brown.edu>2024-05-07 07:00:43 -0400
commitbc515d3acdd94847b6e7aa6135bc234b46161db6 (patch)
tree3184e9797e93b238e672442aea56b210ba5e5751 /hw9/YaoQuantumComputing.jl
parent95eb65429d24a897307601415c716e9042033982 (diff)
add hw9 and hw8
Diffstat (limited to 'hw9/YaoQuantumComputing.jl')
-rw-r--r--hw9/YaoQuantumComputing.jl28
1 files changed, 28 insertions, 0 deletions
diff --git a/hw9/YaoQuantumComputing.jl b/hw9/YaoQuantumComputing.jl
new file mode 100644
index 0000000..36c22d6
--- /dev/null
+++ b/hw9/YaoQuantumComputing.jl
@@ -0,0 +1,28 @@
+using Yao, YaoPlots
+
+let
+ circuit = chain(2, put(1=>X), put(2=>X))
+ plot(circuit)
+end
+
+
+begin
+ bellcircuit = chain(2, put(1=>H), control(1, 2=>X))
+ plot(bellcircuit)
+end
+
+
+q1 = ArrayReg(bit"00") #creating the system of two qubits with state |00>
+println(state(q1))
+println(q1 |> r->measure(r, nshots=10))
+
+a = (q1 |> bellcircuit)
+println(state(a))
+println(a |> r->measure(r, nshots=10))
+
+
+reversebellcircuit = chain(2, control(1,2=>X), put(1=>H))
+plot(reversebellcircuit)
+
+b = (a |> reversebellcircuit)
+println(state(b)) \ No newline at end of file