Skip to content

Instantly share code, notes, and snippets.

@Madsy
Last active March 3, 2018 06:53
Show Gist options
  • Save Madsy/3bea8cb41621a4804cf6a194756d721e to your computer and use it in GitHub Desktop.
Save Madsy/3bea8cb41621a4804cf6a194756d721e to your computer and use it in GitHub Desktop.
void S_to_bit_vector(u32* S, int count, u32* out){
for(int i = 0; i < count; i++){
//assuming 32-bit integers
u32 integer_index = S[i] / 32u;
//mask all bits that fit
u32 bit_index = S[i] & 31;
out[integer_index] |= 1<<bit_index;
}
}
inline u32 f_S(u32* S_bv, u32 s){
u32 integer_index = s / 32u;
u32 bit_index = s & 31;
return S_bv[integer_index] & (1<<bit_index);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment