Skip to content

Commit

Permalink
fix codefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Sep 12, 2024
1 parent 7c85e34 commit 74bd419
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pennylane_lightning/lightning_tensor/_tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ def svd_split(Mat, site_shape, max_bond_dim):


def decompose_dense(psi, n_wires, site_shape, max_bond_dim):
"""Decompose a dense state vector/gate matrix into MPS/MPO sites."""
Ms = [[] for _ in range(n_wires)]
site_len = np.prod(site_shape)
psi = np.reshape(psi, (site_len, -1))

U, Vd = svd_split(psi, site_shape, max_bond_dim)

Ms[0] = U
Ms[0] = U.reshape(tuple(site_shape + [-1]))
bondL = Vd.shape[0]
psi = Vd

Expand All @@ -68,10 +69,7 @@ def decompose_dense(psi, n_wires, site_shape, max_bond_dim):
psi = Vd
bondL = Vd.shape[0]

Ms[n_wires - 1] = Vd

Ms[0] = Ms[0].reshape(tuple(site_shape + [-1]))
Ms[-1] = Ms[-1].reshape(tuple([-1] + site_shape))
Ms[-1] = Vd.reshape(tuple([-1] + site_shape))

return Ms

Expand Down

0 comments on commit 74bd419

Please sign in to comment.