import qiskit

from qiskit import QuantumCircuit

# creating a quantum circuit
qc = QuantumCircuit(3)

qc.z(0)

qc.s(1)

qc.t(2)

qc.cx(0,1)

qc.h(2)

qc.ccx(0, 1, 2)

qc.draw(output='mpl')


# inverse of the quantum circuit
inverse_qc = qc.inverse()

# to draw the quantum circuit
inverse_qc.draw(output='mpl')

# If we measure the quantum circuit's each qubit's states
qc.measure()

# to draw the quantum circuit
qc.draw(output='mpl')

# inverse of the measured quantum circuit's qubit is not possible
inverse_qc = qc.inverse()
qc.measure()
# to draw the quantum circuit
inverse_qc.draw(output='mpl')

# creating a quantum circuit
m_circuit = QuantumCircuit(3)

m_circuit.h(2)
m_circuit.ccx(0, 1, 2)
m_circuit.cz(2, 1)

# draw the circuit
m_circuit.draw(output='mpl')


m_gate = m_circuit.to_gate()

type(m_gate)

new_circuit = QuantumCircuit(5)

new_circuit.append(m_gate, [1, 2, 4])

new_circuit.draw(output='mpl')

#decompose the circuit
new_circuit.decompose().draw(output='mpl')



from qiskit import QuantumCircuit, transpile, Aer

my_circuit = QuantumCircuit(3)
my_circuit.t(1)
my_circuit.h(0)
my_circuit.ccx(2,1,0)
my_circuit.s(2)
my_circuit.t(0)

my_circuit.draw()


my_gate = my_circuit.to_gate()
my_gate

my_inv_gate = my_gate.inverse()
my_inv_gate

my_inv_gate.name = 'My Inverse Gate'

new_circuit = QuantumCircuit(3)
new_circuit.append(my_inv_gate, [0,1,2])
new_circuit.draw()

new_circuit.decompose().draw()

my_circuit = QuantumCircuit(2)
my_circuit.cx(1,0)
my_circuit.cx(0,1)
my_circuit.cx(1,0)

my_circuit.draw()

my_gate = my_circuit.to_gate()

my_gate.name = "My Gate"

my_controlled_gate = my_gate.control()

new_circuit = QuantumCircuit(3)
new_circuit.append(my_controlled_gate, [0, 1, 2])
new_circuit.draw()

new_circuit.decompose().draw()

from qiskit import Aer, IBMQ, QuantumCircuit, execute, transpile, assemble
from qiskit.providers.aer.noise import NoiseModel
from qiskit.visualization import histogram

my_qc = QuantumCircuit(5)
my_qc.h(0)
for q in range(4):
    my_qc.cx(0, q+1)
my_qc.measure_all()
my_qc.draw()

## What is the qsphere ?

## What is the unitary simulator ?

## How can i convert a Unitary Matrix to a set of One and Two Qubit gates ?

## How can i change qiskit's defoult behaviour ?

## How do i use parameterization circuit in Qiskit ?

## Why does qiskit order it's qubit the way it does ?

## How i combine two quantum circuits ?

## What is the difference between gates and instructions ?

## How can i use a specific version of qiskit ?

## How can i implement a multi controlled Toffoli Gate ?

## How can i monitor a job send to IBM Quantum ?

## How can i convert a quantum circuit to QASM ?

my_circuit = QuantumCircuit(3)
my_circuit.t(1)
my_circuit.h(0)
my_circuit.ccx(2,1,0)
my_circuit.s(2)
my_circuit.t(0)

my_circuit.draw('latex')
my_circuit.draw('latex_source')
print(my_circuit.draw('latex_source'))


## How can i bundle several circuit into a single job ?

## How can i save circuit Drawings to Different File Types ?

## How can i contruct a quantum volume circuit ?

## What trick can i do with draw methods ?

## How i can find reduced quantum states using qiskit ?

## In What different ways can i draw a quantum circuit ?

## How can i use a classical register for quantum compuation ?

## What is circuit depth and how can i calculate it ?

## How can i choose initial layout for the traspiler ?

## What are the Ancillary Qubits and how are they usefull ?

## What are registers ?

## How can i create a custom gate from matrix ?

## How can i find expectation value for an operator ?

## How can i measure the qubit midway through a quantum circuit ?

## How can i transpile a quantum circuit ?

## How can i make a noise model with qiskit ?

## How can i create a custome controlled gate ?

## How can i choose the best backend from a provider ?

## How can i perform state tomography ?

## How can i reset a qubit in a quantum circuit

## How do i perform a unitary projection in a quantum circuit ?

## How do i debuge an issue in transpiler ? 

## How can i estimate Pi using a quantum computer ?

## How do i initialize a mixed states ?

## What is gate fidelity and how do i canculate it ?

## How do i check the state fedility with noisy simulator ?

## How do i change the fitter algorithm in a state tomography experiment ?

