Skip to content

Commit

Permalink
Speed up wavefunction coefficient generation (#18)
Browse files Browse the repository at this point in the history
* Make an index map while generating coeffs to avoid redundant searching

* typo

* Update qiskit_addon_dice_solver/dice_solver.py

Co-authored-by: Kevin J. Sung <[email protected]>

---------

Co-authored-by: Kevin J. Sung <[email protected]>
  • Loading branch information
caleb-johnson and kevinsung authored Sep 23, 2024
1 parent e03b000 commit fe265cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qiskit_addon_dice_solver/dice_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,14 @@ def _construct_ci_vec_from_addresses_amplitudes(
num_dets = len(uniques)
ci_vec = np.zeros((num_dets, num_dets))

addr_map = {uni_addr: i for i, uni_addr in enumerate(uniques)}

for idx, address in enumerate(addresses):
address_a = address[0]
address_b = address[1]

i = np.where(uniques == address_a)[0][0]
j = np.where(uniques == address_b)[0][0]
i = addr_map[address_a]
j = addr_map[address_b]
ci_vec[i, j] = amps[idx]

return ci_vec

0 comments on commit fe265cf

Please sign in to comment.