%matplotlib inline
import numpy as np
import IPython
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit,ClassicalRegister,QuantumRegister
from qiskit import BasicAer
from qiskit.tools.jupyter import *
from qiskit.visualization import *
import seaborn as sns
sns.set()

from helper import *

def circuit1():
    qc = QuantumCircuit(2,2)
    qc.h(0)
    return qc

hqc = circuit1()
drawCircuit_2q(hqc)

hqc = circuit1()
writeState(hqc)

hqc = circuit1()
simCircuit(hqc)

hqc = circuit1()
blochSphere(hqc)

hqc = circuit1()
drawCircuit_2q(hqc)

I = np.eye(2,2)
H = 1/np.sqrt(2)*np.array([[1,1],[1,-1]])
U = np.kron(I,H)
print(U)

ket_00 = np.array([1,0,0,0])
np.dot(U,ket_00)

hqc = circuit1()
plotMatrix(hqc)

def circuit2():
    qc = QuantumCircuit(2,2)
    qc.h(0)
    qc.h(1)
    return qc

hqc = circuit2()
drawCircuit_2q(hqc)

hqc = circuit2()
writeState(hqc)

def getPhaseSeq():
    phaseDic = []
    
    qc0 = QuantumCircuit(2,2)
    
    qc1 = QuantumCircuit(2,2)
    qc1.h(0)
    qc1.h(1)
    
    for iqc in [qc0,qc1]:
        phaseDic.append(getPhase(iqc))
    return phaseDic    

drawPhase(getPhaseSeq())

hqc = circuit2()
simCircuit(hqc)

hqc = circuit2()
drawCircuit_2q(hqc)

H = 1/np.sqrt(2)*np.array([[1,1],[1,-1]])
U = np.kron(H,H)
print(U)

ket = np.array([1,0,0,0])
np.dot(U,ket)

hqc = circuit2()
plotMatrix(hqc)

n = 3
q = QuantumRegister(n)
c = ClassicalRegister(n)
hqc3 = QuantumCircuit(q,c)
for k in range(3):
    hqc3.h(q[k])
hqc3.barrier()
hqc3.measure(q,c)
style = {'backgroundcolor': 'lavender'}
hqc3.draw(output='mpl', style = style)











