from qiskit import *
from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram


qc = QuantumCircuit(3)

qc.x(0)
qc.x(1)
qc.cswap(0,1,2)

qc.draw('mpl')

backend = Aer.get_backend('unitary_simulator')

out = execute(qc,backend).result().get_unitary()

from qiskit_textbook.tools import array_to_latex
array_to_latex(out, pretext = "\\text{UnitaryMatrix} = ")

backend = Aer.get_backend('statevector_simulator')

out = execute(qc,backend).result().get_statevector()

array_to_latex(out, pretext = "\\text{Statevector} = ")

plot_bloch_multivector(out)

#execute the circuit and get the plain result
out = execute(qc,backend).result()
#getting the count of the result
counts = out.get_counts()
#plotting the histogram
plot_histogram(counts)

