Skip to content

Commit

Permalink
Update rpkt.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed May 27, 2024
1 parent eeac050 commit 5a9b047
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rpkt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ auto closest_transition(const double nu_cmf, const int next_trans) -> int
// will find the highest frequency (lowest index) line with nu_line <= nu_cmf
// lower_bound matches the first element where the comparison function is false

const auto *matchline =
std::lower_bound(globals::linelist, globals::linelist + globals::nlines, nu_cmf,
[](const auto &line, const double nu_cmf) -> bool { return line.nu > nu_cmf; });
const int matchindex = static_cast<int>(matchline - globals::linelist);
const int matchindex =
std::distance(globals::linelist,
std::lower_bound(globals::linelist, globals::linelist + globals::nlines, nu_cmf,
[](const auto &line, const double nu_cmf) -> bool { return line.nu > nu_cmf; }));

if (matchindex >= globals::nlines) {
return -1;
}
Expand Down

0 comments on commit 5a9b047

Please sign in to comment.