Skip to content

Commit

Permalink
[BUGFIX] Small typo fixes in mps demo (#1269)
Browse files Browse the repository at this point in the history
fixing #1267
  • Loading branch information
Qottmann authored Nov 21, 2024
1 parent dc10cb5 commit cf00c6f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demonstrations/tutorial_mps.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2024-09-29T00:00:00+00:00",
"dateOfLastModification": "2024-10-11T00:00:00+00:00",
"dateOfLastModification": "2024-11-20T00:00:00+00:00",
"categories": [
"Quantum Computing",
"Algorithms",
Expand Down
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 cf00c6f

Please sign in to comment.