Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apparently, there was a off-by-one error issue when interpolating. #276

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inline void CollisionPartner ::interpolate_collision_coefficients(const Real tem
if (t == 0) {
Ce_intpld() = Ce[0];
Cd_intpld() = Cd[0];
} else if (t == ntmp - 1) {
} else if (t == ntmp) {
Ce_intpld() = Ce[ntmp - 1];
Cd_intpld() = Cd[ntmp - 1];
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/interpolation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tools/types.hpp"

/// Binary search for the index of a value right above a value in a list
/// Binary search for the index with value just above the given value
/// @param[in] x: vector of tabulated argument values
/// @param[in] value: value to search for
/// @return index of x table just above value
Expand All @@ -12,7 +12,7 @@ inline Size search(const Real1& x, const Real value) {
Size stop = x.size() - 1;

if (value >= x[stop]) {
return stop;
return stop + 1; // need additional value to indicate out of bounds for max value
} else if (value <= x[start]) {
return start;
}
Expand Down
Loading