Skip to content

Commit

Permalink
Issue #46 in lassi.citools.envaddr2fragaddr
Browse files Browse the repository at this point in the history
Refactor to avoid construction of large-dimensional ndarray. Where
else does ndarray dimensionality limit constrain LASSI number of
fragments?
  • Loading branch information
MatthewRHermes committed Nov 8, 2023
1 parent 754c824 commit aa1b088
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions my_pyscf/lassi/citools.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ def envaddr2fragaddr (lroots):
for iroot in range (nroots):
j = offs[iroot]
i = j - nprods[iroot]
addrs = np.stack (np.meshgrid (*[np.arange(l) for l in lroots[::-1,iroot]],
indexing='ij'), axis=0).astype (int)
addrs = addrs.reshape (nfrags, nprods[iroot])[::-1,:]
fragaddr[:,i:j] = addrs
for ifrag in range (nfrags):
prods_before = np.product (lroots[:ifrag,iroot], axis=0)
prods_after = np.product (lroots[ifrag+1:,iroot], axis=0)
addrs = np.repeat (np.arange (lroots[ifrag,iroot]), prods_before)
addrs = np.tile (addrs, prods_after)
fragaddr[ifrag,i:j] = addrs
rootaddr[i:j] = iroot
return rootaddr, fragaddr

Expand Down

0 comments on commit aa1b088

Please sign in to comment.