From 468266c723d36be79527c1a75f873fd0428a60bd Mon Sep 17 00:00:00 2001 From: Korbinian Kottmann <43949391+Qottmann@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:54:40 +0200 Subject: [PATCH] Fix a bug in dense_to_mps (#1237) Bug reported by @hsim13372 , thanks a lot! Quick fix. This was missed because the function is just used to show the dimensionality. --- demonstrations/tutorial_mps.metadata.json | 2 +- demonstrations/tutorial_mps.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demonstrations/tutorial_mps.metadata.json b/demonstrations/tutorial_mps.metadata.json index 73c88e90a5..5ae77568dc 100644 --- a/demonstrations/tutorial_mps.metadata.json +++ b/demonstrations/tutorial_mps.metadata.json @@ -6,7 +6,7 @@ } ], "dateOfPublication": "2024-09-29T00:00:00+00:00", - "dateOfLastModification": "2024-10-07T00:00:00+00:00", + "dateOfLastModification": "2024-10-11T00:00:00+00:00", "categories": [ "Quantum Computing", "Algorithms", diff --git a/demonstrations/tutorial_mps.py b/demonstrations/tutorial_mps.py index 4c58a92c8a..27ca52a11a 100644 --- a/demonstrations/tutorial_mps.py +++ b/demonstrations/tutorial_mps.py @@ -330,7 +330,7 @@ def dense_to_mps(psi, bond_dim): Ms.append(U) Ss.append(Ss) bondL = Vd.shape[0] - psi = Vd + 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...)]