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

Support special case of creating PGM index for only one input element #60

Conversation

yangzq50
Copy link
Contributor

@yangzq50 yangzq50 commented Nov 1, 2024

Support special case of creating PGM index for only one input element

Update piecewise_linear_model.hpp

Fix #61

Fix existing bugs:

  • If start = 0, end = 1, we will get end - 2 == size_t(-1), which will cause heap-buffer-overflow when we call in(end - 2).
  • If start = 0, end = 1, then we have start == end - 1. We should not call add_point() twice for the first element.

@yangzq50 yangzq50 changed the title Update piecewise_linear_model.hpp Support special case of creating PGM index for only one input element Nov 1, 2024
@@ -303,7 +303,7 @@
add_point(in(i), i);
}
}
if (in(end - 1) != in(end - 2))
if (end >= start + 2 && in(end - 1) != in(end - 2))

Check notice

Code scanning / CodeQL

Equality test on floating-point values Note

Equality checks on floating point values can yield unexpected results.
@yangzq50
Copy link
Contributor Author

Any comments?

@gvinciguerra gvinciguerra merged commit c6fcf3d into gvinciguerra:master Nov 28, 2024
6 checks passed
@gvinciguerra
Copy link
Owner

Amazing. Thanks a lot @yangzq50!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: cannot create PGM index for only one element
2 participants