Skip to content
Snippets Groups Projects
Commit e422044f authored by Rahil Doshi's avatar Rahil Doshi
Browse files

Refactor interpolate_binary_search_cpp.h

parent 1d67844f
No related merge requests found
Pipeline #77631 passed with stage
in 24 seconds
......@@ -33,12 +33,13 @@ double interpolate_binary_search_cpp(
}
}
// Linear interpolation
const double x1 = arrs.y_bs[right];
const double x2 = arrs.y_bs[left];
const double y1 = arrs.x_bs[right];
const double y2 = arrs.x_bs[left];
// Get interpolation points
const double x1 = arrs.x_bs[left];
const double x2 = arrs.x_bs[right];
const double y1 = arrs.y_bs[left];
const double y2 = arrs.y_bs[right];
const double slope = (y2 - y1) / (x2 - x1);
return y1 + slope * (y_target - x1);
// Linear interpolation
const double inv_slope = (x2 - x1) / (y2 - y1);
return x1 + inv_slope * (y_target - y1);
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment