%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# Importing standard Qiskit libraries 
from qiskit import QuantumCircuit, execute
from qiskit.providers.aer import QasmSimulator
from qiskit.visualization import *
from qiskit.quantum_info import *

q1_sv = Statevector.from_label('0')
q2_sv = Statevector.from_label('1')
prod_sv = q1_sv.tensor(q2_sv)
print(prod_sv.data)

prod_sv2 = Statevector.from_label('01')
print(prod_sv2.data)

op1 = Operator.from_label('X')
op2 = Operator.from_label('I')
prod_op = op1.tensor(op2)
print(prod_op.data)

prod_op2 = Operator.from_label('XI')
print(prod_op2.data)

q1_sv_1 = q1_sv.evolve(op1)
q2_sv_1 = q2_sv.evolve(op2)
prod_sv_1 = q1_sv_1.tensor(q2_sv_1)

prod_sv2_1 = prod_sv2.evolve(prod_op2)

prod_sv_1.equiv(prod_sv2_1)

qc = QuantumCircuit(2)
# All qubits start in the |0> state
qc.x(0)
qc.draw(output='mpl')
# qc.measure(0,0) # First argument is the qubit to be measured

print(Operator(qc).data)

Operator(qc).equiv(prod_op2)

qc_rev = qc.reverse_bits()
qc_rev.draw(output='mpl')

print(Operator(qc_rev).data)

Operator(qc_rev).equiv(prod_op2)

qc2 = QuantumCircuit(2)
qc2.h([0,1])
qc2.measure_all()
qc2.draw(output='mpl')

job = execute(qc2, backend=QasmSimulator(), shots=8192)
result = job.result()
result.get_counts()

qc2_rev = qc2.reverse_bits()
qc2_rev.draw(output='mpl')

job = execute(qc2_rev, backend=QasmSimulator(), shots=8192)
result = job.result()
result.get_counts()

qc = QuantumCircuit(2)
qc.cx(0,1)
qc.draw(output='mpl')

cnot_op = Operator(qc)
sv = Statevector.from_label('0+') # Little Endian
sv2 = sv.evolve(cnot_op)

plot_bloch_multivector(sv)

plot_bloch_multivector(sv2)

sv2.data

