Skip to content

Commit

Permalink
Small typo fixes in mps demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Qottmann committed Nov 19, 2024
1 parent 22a96cd commit 92d38c5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions demonstrations/tutorial_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
##############################################################################
#
# We are later going to do the same trick with state vectors.
# Note that the compressed information is encoded in :math:`U,` :math:`S` and :math:`V^\dagger.`
# Note that the compressed information is encoded in :math:`U,` :math:`\Lambda` and :math:`V^\dagger.`
# If we want to retrieve the actual image :math:`M` (or state vector), we still need to reconstruct the full :math:`334 \times 542` pixels.
# Luckily, as we will later see in the case of MPS, we can retrieve all relevant information efficiently from the compressed components without ever
# having to reconstruct the full state vector.
Expand Down Expand Up @@ -209,7 +209,7 @@
#
# Note that because :math:`\Lambda` is diagonal, it has the same virtual index on either side.
#
# We keep the :math:`U` tensors. We want to maintain the convention that they are of the shape ``(virtual_left, physical, virtual_right)`.`
# We keep the :math:`U` tensors. We want to maintain the convention that they are of the shape ``(virtual_left, physical, virtual_right).``
# Because there is no virtual index on the left for the first site, we introduce a dummy index of size ``1``.
# This is just to make the bookkeeping of the final MPS a bit simpler, as all tensors have the same shape structure.

Expand Down Expand Up @@ -328,15 +328,15 @@ def dense_to_mps(psi, bond_dim):
U, S, Vd = split(psi, bond_dim) # psi[2, (2x2x..)] = U[2, mu] S[mu] Vd[mu, (2x2x2x..)]

Ms.append(U)
Ss.append(Ss)
Ss.append(S)
bondL = Vd.shape[0]
psi = np.tensordot(np.diag(S), Vd, 1)

for _ in range(n-2):
psi = np.reshape(psi, (2*bondL, -1)) # reshape psi[2 * bondL, (2x2x2...)]
U, S, Vd = split(psi, bond_dim) # psi[2, (2x2x..)] = U[2, mu] S[mu] Vd[mu, (2x2x2x..)]
Ms.append(U)
Ss.append(Ss)
Ss.append(S)

psi = np.tensordot(np.diag(S), Vd, 1)
bondL = Vd.shape[0]
Expand Down

0 comments on commit 92d38c5

Please sign in to comment.