From bc515d3acdd94847b6e7aa6135bc234b46161db6 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Tue, 7 May 2024 07:00:43 -0400 Subject: add hw9 and hw8 --- hw9/YaoQuantumComputing.jl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 hw9/YaoQuantumComputing.jl (limited to 'hw9/YaoQuantumComputing.jl') 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 -- cgit v1.2.3-70-g09d2