Loading notebooks/Half-Adder-CI.ipynb +11 −10 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python import cirq q0, q1, q2, q3 = cirq.LineQubit.range(4) circuit = cirq.Circuit() circuit.append(cirq.X(q1)) #circuit.append(cirq.X(q1)) circuit.append(cirq.X(q1)) circuit.append(cirq.CNOT(q0, q2)) circuit.append(cirq.CNOT(q1, q2)) circuit.append(cirq.CCNOT(q0, q1, q3)) circuit.append(cirq.measure(q2, q3, key='result')) print(circuit) s = cirq.Simulator() samples = s.run(circuit, repetitions=1000) counts = samples.histogram(key= 'result') counts = samples.histogram(key= 'resul') print(counts) ``` %% Output ┌──┐ 0: ─────@────────────@───────────────── │ │ 1: ────X┼────X───@───@───────────────── │ │ │ 2: ─────X────────X───┼───M('result')─── │ │ 3: ──────────────────X───M───────────── 0: ─────@────────@──────────────── │ │ 1: ────X┼────@───@──────────────── │ │ │ 2: ─────X────X───┼───M('resul')─── │ │ 3: ──────────────X───M──────────── └──┘ Counter({0: 1000}) Counter({2: 1000}) %% Cell type:code id: tags: ``` python ``` notebooks/Lekha.ipynb 0 → 100644 +69 −0 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python from qiskit import QuantumCircuit from qiskit.extensions import UnitaryGate import numpy as np matrix = [[0, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 0], [0, 1, 0, 0]] gate = UnitaryGate(matrix) circuit = QuantumCircuit(3) circuit.append(gate, [0, 1]) ``` %% Output <qiskit.circuit.instructionset.InstructionSet at 0x7f9a41460d90> %% Cell type:code id: tags: ``` python m2 = np.square(matrix) print(m2) ``` %% Output [[0 0 0 1] [0 0 1 0] [1 0 0 0] [0 1 0 0]] %% Cell type:code id: tags: ``` python from numpy import linalg as LA eigenvalues, eigenvectors = LA.eig(m2) print(eigenvectors) ``` %% Output [[ 5.00000000e-01+0.00000000e+00j 2.63941871e-16-5.00000000e-01j 2.63941871e-16+5.00000000e-01j -5.00000000e-01+0.00000000e+00j] [ 5.00000000e-01+0.00000000e+00j -2.85804968e-18+5.00000000e-01j -2.85804968e-18-5.00000000e-01j -5.00000000e-01+0.00000000e+00j] [-5.00000000e-01+0.00000000e+00j -5.00000000e-01+0.00000000e+00j -5.00000000e-01-0.00000000e+00j -5.00000000e-01+0.00000000e+00j] [-5.00000000e-01+0.00000000e+00j 5.00000000e-01-1.34144886e-16j 5.00000000e-01+1.34144886e-16j -5.00000000e-01+0.00000000e+00j]] %% Cell type:code id: tags: ``` python circuit.draw(output='mpl') ``` %% Output <Figure size 287.496x284.278 with 1 Axes> %% Cell type:code id: tags: ``` python ``` Loading
notebooks/Half-Adder-CI.ipynb +11 −10 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python import cirq q0, q1, q2, q3 = cirq.LineQubit.range(4) circuit = cirq.Circuit() circuit.append(cirq.X(q1)) #circuit.append(cirq.X(q1)) circuit.append(cirq.X(q1)) circuit.append(cirq.CNOT(q0, q2)) circuit.append(cirq.CNOT(q1, q2)) circuit.append(cirq.CCNOT(q0, q1, q3)) circuit.append(cirq.measure(q2, q3, key='result')) print(circuit) s = cirq.Simulator() samples = s.run(circuit, repetitions=1000) counts = samples.histogram(key= 'result') counts = samples.histogram(key= 'resul') print(counts) ``` %% Output ┌──┐ 0: ─────@────────────@───────────────── │ │ 1: ────X┼────X───@───@───────────────── │ │ │ 2: ─────X────────X───┼───M('result')─── │ │ 3: ──────────────────X───M───────────── 0: ─────@────────@──────────────── │ │ 1: ────X┼────@───@──────────────── │ │ │ 2: ─────X────X───┼───M('resul')─── │ │ 3: ──────────────X───M──────────── └──┘ Counter({0: 1000}) Counter({2: 1000}) %% Cell type:code id: tags: ``` python ```
notebooks/Lekha.ipynb 0 → 100644 +69 −0 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python from qiskit import QuantumCircuit from qiskit.extensions import UnitaryGate import numpy as np matrix = [[0, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 0], [0, 1, 0, 0]] gate = UnitaryGate(matrix) circuit = QuantumCircuit(3) circuit.append(gate, [0, 1]) ``` %% Output <qiskit.circuit.instructionset.InstructionSet at 0x7f9a41460d90> %% Cell type:code id: tags: ``` python m2 = np.square(matrix) print(m2) ``` %% Output [[0 0 0 1] [0 0 1 0] [1 0 0 0] [0 1 0 0]] %% Cell type:code id: tags: ``` python from numpy import linalg as LA eigenvalues, eigenvectors = LA.eig(m2) print(eigenvectors) ``` %% Output [[ 5.00000000e-01+0.00000000e+00j 2.63941871e-16-5.00000000e-01j 2.63941871e-16+5.00000000e-01j -5.00000000e-01+0.00000000e+00j] [ 5.00000000e-01+0.00000000e+00j -2.85804968e-18+5.00000000e-01j -2.85804968e-18-5.00000000e-01j -5.00000000e-01+0.00000000e+00j] [-5.00000000e-01+0.00000000e+00j -5.00000000e-01+0.00000000e+00j -5.00000000e-01-0.00000000e+00j -5.00000000e-01+0.00000000e+00j] [-5.00000000e-01+0.00000000e+00j 5.00000000e-01-1.34144886e-16j 5.00000000e-01+1.34144886e-16j -5.00000000e-01+0.00000000e+00j]] %% Cell type:code id: tags: ``` python circuit.draw(output='mpl') ``` %% Output <Figure size 287.496x284.278 with 1 Axes> %% Cell type:code id: tags: ``` python ```