Skip to content

Commit

Permalink
Fival encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Oct 27, 2024
1 parent 96f5c5f commit 2dec8e5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions fival_encoding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# "Fival encoding"
# https://arxiv.org/abs/hep-th/9409150 adopts a definition of a "maximally-entangled" state
# that relies on two qudits with the same (but otherwise arbitrary) dimensional cardinality.
# If padded with 0-amplitude entries so that the new dimensionality of the modified state
# has a cardinality that factors as only first powers of unique prime numbers, then the
# Schmidt rank becomes 1, and the state appears separable in the "Fival encoding."

import sys
import numpy as np

from pyqrack import QrackSimulator


def main():
qsim = QrackSimulator(2)
qsim.h(0)
qsim.h(1)
qsim.mcz([0], 1)
qsim.h(1)

ket = qsim.out_ket() + [0, 0]
print(ket)

r = np.reshape(ket, (2, 3))
U, S, Vh = np.linalg.svd(r)
ket1 = U[:, [0]]
ket2 = Vh[:, [0]]

print("2 by 3:")
print(np.kron(ket1, ket2))
print(S)

if __name__ == '__main__':
sys.exit(main())

0 comments on commit 2dec8e5

Please sign in to comment.