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

Creating select_upper and selectz_upper in EliasFano.hpp #19

Closed
thomasdwu opened this issue Nov 29, 2022 · 7 comments
Closed

Creating select_upper and selectz_upper in EliasFano.hpp #19

thomasdwu opened this issue Nov 29, 2022 · 7 comments

Comments

@thomasdwu
Copy link

In EliasFano.hpp, line 119, upper_bits.size has the term (num_ones + (num_bits >> l) + 1), which is converted to the number of words by adding 63 and dividing by 64. To be consistent, shouldn't lines 137 and 138 call SimpleSelectHalf and SimpleSelectZeroHalf by also adding 1 to (num_ones + (num_bits >> l)? That way, in SimpleSelectHalf, line 83, and SimpleSelectZeroHalf, line 83, the value of num_words will be equal to upper_bits.size.

@vigna
Copy link
Owner

vigna commented Nov 29, 2022

Er... or maybe the +1 is unnecessary. I have to think about this—there's clearly an off-by-one in one of the two locations.

@thomasdwu
Copy link
Author

thomasdwu commented Nov 29, 2022 via email

@thomasdwu
Copy link
Author

thomasdwu commented Nov 29, 2022 via email

@vigna
Copy link
Owner

vigna commented Nov 29, 2022

Can you show me the example?

@thomasdwu
Copy link
Author

thomasdwu commented Nov 29, 2022 via email

@vigna
Copy link
Owner

vigna commented Jun 11, 2023

Yes, you're right. The point is that if the upper bound u is not a multiple of 2𝓁, then there might be elements whose value of the upper bits is u >> 𝓁, which means you need that position to be part of the upper bits.

If you can give me a real name I'll thank you in the CHANGES section.

@vigna vigna closed this as completed Jun 11, 2023
@thomasdwu
Copy link
Author

thomasdwu commented Jun 12, 2023 via email

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

No branches or pull requests

2 participants