Skip to content

Commit

Permalink
* Ignore terms with 0 coefficients
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Pisal <spisal@nvidia.com>
  • Loading branch information
sacpis committed Nov 18, 2024
1 parent 7b3fbba commit 9bde3da
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions runtime/cudaq/spin/spin_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,11 @@ spin_op &spin_op::operator+=(const spin_op &v) noexcept {

for (auto [term, coeff] : tmpv.terms) {
auto iter = terms.find(term);
if (iter != terms.end())
if (iter != terms.end()) {
iter->second += coeff;
else
if (std::abs(iter->second) < 1e-12)
terms.erase(iter);
} else
terms.emplace(term, coeff);
}

Expand Down

0 comments on commit 9bde3da

Please sign in to comment.