from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit, execute, Aer
import os
os.chdir('..')
from Quantum_incrementor import controlled_quantum_incrementor
os.chdir('Test')


def Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits, ancilla_qubit
    ):
    circuit = controlled_quantum_incrementor(-epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    circuit = controlled_quantum_incrementor(epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    return circuit


def Dirac_QW_coin(epsilon, mass, circuit, spin_qubit):
    circuit.rx(2 * mass * epsilon, spin_qubit)
    return circuit


def Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit):
    circuit = Dirac_QW_coin(epsilon, mass, circuit, spin_qubit)
    circuit = Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits,
        ancilla_qubit)
    return circuit


n_qubits_position = 3
epsilon = 1
mass = 0.1
spin_qubit = QuantumRegister(1)
ancilla_qubit = QuantumRegister(1)
position_qubits = QuantumRegister(n_qubits_position)
clbits = ClassicalRegister(2 + n_qubits_position)
circuit = QuantumCircuit(position_qubits, clbits)
circuit.add_register(spin_qubit)
circuit.add_register(ancilla_qubit)
circuit = Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit)
circuit.measure(circuit.qubits, clbits)
backend = Aer.get_backend('qasm_simulator')
job_sim = execute(circuit, backend, shots=10000)
sim_result = job_sim.result()
print(sim_result.get_counts(circuit))

c080f1179e537c5f5e928938c33027b120147ac0
<mask token>


def Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits, ancilla_qubit
    ):
    circuit = controlled_quantum_incrementor(-epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    circuit = controlled_quantum_incrementor(epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    return circuit


def Dirac_QW_coin(epsilon, mass, circuit, spin_qubit):
    circuit.rx(2 * mass * epsilon, spin_qubit)
    return circuit


def Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit):
    circuit = Dirac_QW_coin(epsilon, mass, circuit, spin_qubit)
    circuit = Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits,
        ancilla_qubit)
    return circuit


<mask token>

<mask token>
os.chdir('..')
<mask token>
os.chdir('Test')


def Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits, ancilla_qubit
    ):
    circuit = controlled_quantum_incrementor(-epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    circuit = controlled_quantum_incrementor(epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    return circuit


def Dirac_QW_coin(epsilon, mass, circuit, spin_qubit):
    circuit.rx(2 * mass * epsilon, spin_qubit)
    return circuit


def Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit):
    circuit = Dirac_QW_coin(epsilon, mass, circuit, spin_qubit)
    circuit = Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits,
        ancilla_qubit)
    return circuit


<mask token>
circuit.add_register(spin_qubit)
circuit.add_register(ancilla_qubit)
<mask token>
circuit.measure(circuit.qubits, clbits)
<mask token>
print(sim_result.get_counts(circuit))

<mask token>
os.chdir('..')
<mask token>
os.chdir('Test')


def Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits, ancilla_qubit
    ):
    circuit = controlled_quantum_incrementor(-epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    circuit = controlled_quantum_incrementor(epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    return circuit


def Dirac_QW_coin(epsilon, mass, circuit, spin_qubit):
    circuit.rx(2 * mass * epsilon, spin_qubit)
    return circuit


def Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit):
    circuit = Dirac_QW_coin(epsilon, mass, circuit, spin_qubit)
    circuit = Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits,
        ancilla_qubit)
    return circuit


n_qubits_position = 3
epsilon = 1
mass = 0.1
spin_qubit = QuantumRegister(1)
ancilla_qubit = QuantumRegister(1)
position_qubits = QuantumRegister(n_qubits_position)
clbits = ClassicalRegister(2 + n_qubits_position)
circuit = QuantumCircuit(position_qubits, clbits)
circuit.add_register(spin_qubit)
circuit.add_register(ancilla_qubit)
circuit = Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit)
circuit.measure(circuit.qubits, clbits)
backend = Aer.get_backend('qasm_simulator')
job_sim = execute(circuit, backend, shots=10000)
sim_result = job_sim.result()
print(sim_result.get_counts(circuit))

from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit, execute, Aer
import os
os.chdir('..')
from Quantum_incrementor import controlled_quantum_incrementor
os.chdir('Test')


def Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits, ancilla_qubit
    ):
    circuit = controlled_quantum_incrementor(-epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    circuit = controlled_quantum_incrementor(epsilon, circuit, spin_qubit,
        ancilla_qubit, position_qubits)
    circuit.x(spin_qubit)
    return circuit


def Dirac_QW_coin(epsilon, mass, circuit, spin_qubit):
    circuit.rx(2 * mass * epsilon, spin_qubit)
    return circuit


def Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit):
    circuit = Dirac_QW_coin(epsilon, mass, circuit, spin_qubit)
    circuit = Dirac_QW_shift(epsilon, circuit, spin_qubit, position_qubits,
        ancilla_qubit)
    return circuit


n_qubits_position = 3
epsilon = 1
mass = 0.1
spin_qubit = QuantumRegister(1)
ancilla_qubit = QuantumRegister(1)
position_qubits = QuantumRegister(n_qubits_position)
clbits = ClassicalRegister(2 + n_qubits_position)
circuit = QuantumCircuit(position_qubits, clbits)
circuit.add_register(spin_qubit)
circuit.add_register(ancilla_qubit)
circuit = Dirac_QW_step(epsilon, mass, circuit, spin_qubit, position_qubits,
    ancilla_qubit)
circuit.measure(circuit.qubits, clbits)
backend = Aer.get_backend('qasm_simulator')
job_sim = execute(circuit, backend, shots=10000)
sim_result = job_sim.result()
print(sim_result.get_counts(circuit))
