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 <[email protected]>
  • Loading branch information
sacpis committed Nov 8, 2024
1 parent aef4036 commit c20ab81
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 c20ab81

Please sign in to comment.