Beispiel #1
0
    for j in range(1, N - 1, 2):
        gates.append(ZZ(wires=[j, j + 1]))

    gates.append(ZZ(wires=[N - 1, 0]))
    gates.extend([RX(wires=[
        i,
    ]) for i in range(N)])

qc = QuantumCircuit(N,
                    gates,
                    circuit_order='layer',
                    get_phi_per_layer=True,
                    tensorboard=True)
# print(qc.phi_per_layer)
phi = qc.execute()
all_ptr_rhos = partial_trace(qc.phi_per_layer, [0, 1],
                             [-1] + [2 for _ in range(N)])
# vn_entropies = von_neumann_entropy(all_ptr_rhos)
# ry_entropies = renyi_entropy(all_ptr_rhos, alpha=0.99)
qc.initialize()
lam, _ = qc._sess.run(tf.linalg.eigh(all_ptr_rhos))
print(np.sum(lam, axis=1))
#
# rhos, vns, rys = qc._sess.run([all_ptr_rhos, vn_entropies, ry_entropies])
# for p in rhos:
#     print(p)
#     print(np.trace(p))
#
# print(vns)
# print(rys)
Beispiel #2
0
from zyglrox.core.circuit import QuantumCircuit
from zyglrox.core.gates import *
import numpy as np

qc = QuantumCircuit(
    10, [Hadamard(wires=[
        i,
    ]) for i in np.random.randint(0, 9, 100)],
    device='GPU',
    ngpus=1,
    tensorboard=True)
output = qc.execute()
qc.initialize()
print(qc._sess.run(output))