Skip to content

Commit

Permalink
Fix gaussian ops (#531)
Browse files Browse the repository at this point in the history
* removes unused variables in test_tdmprogram

* Makes sure the indices are now sorted

* dummy change

* sorts after creation

* Update strawberryfields/backends/gaussianbackend/ops.py

Co-authored-by: Josh Izaac <josh146@gmail.com>
  • Loading branch information
nquesada and josh146 committed Jan 28, 2021
1 parent 98898e8 commit b39add3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions strawberryfields/backends/gaussianbackend/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def chop_in_blocks_vector(v, idtodelete):
which elements go into vb
"""
idtokeep = list(set(np.arange(len(v))) - set(idtodelete))
idtokeep.sort()
va = v[idtokeep]
vb = v[idtodelete]
return (va, vb)
Expand All @@ -51,7 +52,8 @@ def reassemble(A, idtodelete):
The empty space are filled with zeros (offdiagonal) and ones (diagonals)
"""
ntot = len(A) + len(idtodelete)
ind = set(np.arange(ntot)) - set(idtodelete)
ind = list(set(np.arange(ntot)) - set(idtodelete))
ind.sort()
newmat = np.zeros((ntot, ntot))
for i, i1 in enumerate(ind):
for j, j1 in enumerate(ind):
Expand All @@ -67,7 +69,8 @@ def reassemble_vector(va, idtodelete):
and everywhere else it puts the entries of va
"""
ntot = len(va) + len(idtodelete)
ind = set(np.arange(ntot)) - set(idtodelete)
ind = list(set(np.arange(ntot)) - set(idtodelete))
ind.sort()
newv = np.zeros(ntot)
for j, j1 in enumerate(ind):
newv[j1] = va[j]
Expand Down

0 comments on commit b39add3

Please sign in to comment.