import svect as sv
import numpy as np
from math import pi
import qneural as qn
from matplotlib import pyplot as plt

# =============================================================================
# Entropy Dynamics for a Unitary Quantum Neural Map
# =============================================================================

# =============================================================================
# Part 1 - Preparation
# =============================================================================

# Setup the initial operator to get the initial density
U0 = sv.tensorProd([sv.WHGate(), sv.WHGate()])

# Initialize the network
Net, mult_2 = qn.initialize_network(num_neurons=2,
                                    initial_operator=U0,
                                    type_initial='Unitary',
                                    return_multipliers=True)

print("\nInitial Density")
print(Net.rho)

print("\nLocal Operators")

print("\nNeuron 0")
print(Net.local_operators[0])
import svect as sv
import numpy as np

# Main Operators Used in the Circuit:
H = sv.WHGate()  # Walsh-Haddamard transform
I = sv.unit()  # Unit gate
X = sv.PauliX()  # Pauli X
P0 = sv.proj2x2(False)  # Projector P0 = |0><0|
P1 = sv.proj2x2(True)  # projector P1 = |1><1|

# Circuit Operator
UCircuit = np.dot(
    sv.tensorProd([P0, I]) + sv.tensorProd([P1, X]), sv.tensorProd([H, I]))

# Basis:
basis = sv.basisDef(2)  # we are working with a two register basis

# Initial amplitude:
psi0 = np.zeros(len(basis))
psi0[0] = 1

# Initial ket:
ket = sv.getKet(basis, psi0)

# Implementing the quatum circuit:
print("\nQUANTUM CIRCUIT SIMULATION")
print("\nInitial ket vector:")
sv.showKet(ket)

print("\nFinal ket vector:")
ket = sv.transformKet(UCircuit, ket)