Skip to content

Commit

Permalink
fix bit-order, change names
Browse files Browse the repository at this point in the history
  • Loading branch information
jirigav committed May 7, 2024
1 parent f3669cf commit a7c5a7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/bottomup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ fn brute_force(data: &Data, block_size: usize, deg: usize, k: usize) -> Vec<Hist
let mut bins = vec![0; 2_usize.pow(deg as u32)];
for bits in (0..block_size).combinations(deg) {
compute_bins(&bits, data, deg, &hists, &mut bins, block_size, &mut t);

let hist = Histogram::from_bins(bits, &bins);
best_hists.push(hist);
best_hists.sort_by(|a, b| b.z_score.abs().partial_cmp(&a.z_score.abs()).unwrap());
Expand Down
8 changes: 4 additions & 4 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ pub(crate) struct Args {

/// Number of bits in histograms in brute-force search.
#[arg(short, long, default_value_t = 2)]
pub(crate) deg: usize,
pub(crate) k: usize,

/// Number of best histograms taken for the second step.
#[arg(short, long, default_value_t = 1)]
pub(crate) k: usize,
pub(crate) top: usize,

/// Number of histograms combined in second step.
#[arg(short, long, default_value_t = 1)]
Expand All @@ -52,7 +52,7 @@ pub(crate) fn bits_block_eval(bits: &[usize], block: &[u8]) -> usize {
}

pub(crate) fn bit_value_in_block(bit: usize, block: &[u8]) -> bool {
let (byte_index, offset) = (bit / 8, bit % 8);
let (byte_index, offset) = (bit / 8, 7 - (bit % 8));
((block[byte_index] >> offset) & 1) == 1
}

Expand Down Expand Up @@ -125,7 +125,7 @@ pub(crate) fn _multi_eval2(bits: &[usize], data: &Data, t: &mut Duration) -> usi
if i == data.data[0].len() {
break;
}
let mut result = vec![u128::MAX; l as usize];
let mut result = vec![u128::MAX; l];
for b in bits.iter() {
result = result
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ fn run_bottomup(args: Args) {
let hist = bottomup(
&training_data,
args.block,
args.deg,
args.k,
args.top,
args.max_bits,
args.threads,
);
Expand Down

0 comments on commit a7c5a7a

Please sign in to comment.