Skip to content

Commit

Permalink
fix: fixed wrong values for the number of indices of instanton correc…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
ariostas committed May 18, 2024
1 parent 1933c2c commit 0ee8907
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/instanton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ where

// Compute instanton corrections
let mut inst: Vec<_> = (0..n_indices).map(|_| Polynomial::<T>::new()).collect();
let tasks_inst: Vec<_> = (0..h11).collect();
let tasks_inst: Vec<_> = (0..n_indices).collect();
let tasks_inst_iter = Arc::new(Mutex::new(tasks_inst.iter()));
thread::scope(|s| {
let (tx, rx) = channel();
Expand Down Expand Up @@ -423,10 +423,16 @@ mod tests {
2, 1, -1, -5;];
let result = process_int_nums(intnums.clone(), true);
assert!(result.is_ok());
let (intnum_dict, intnum_idxpairs) = result.unwrap();
let (intnum_dict, intnum_idxpairs, n_indices) = result.unwrap();

let inst_data =
compute_instanton_data(fp, &poly_props, &intnum_idxpairs, 2, &intnum_dict, true);
let inst_data = compute_instanton_data(
fp,
&poly_props,
&intnum_idxpairs,
n_indices,
&intnum_dict,
true,
);
assert!(inst_data.is_ok());
let inst_data = inst_data.unwrap();

Expand Down
22 changes: 18 additions & 4 deletions src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ use std::collections::{HashMap, HashSet};
pub fn process_int_nums(
intnums: DMatrix<i32>,
is_threefold: bool,
) -> Result<(HashMap<(usize, usize, usize), i32>, HashSet<(usize, usize)>), MiscError> {
) -> Result<
(
HashMap<(usize, usize, usize), i32>,
HashSet<(usize, usize)>,
usize,
),
MiscError,
> {
if intnums.ncols() == 0 {
return Err(MiscError::EmptyIntNums);
} else if intnums.nrows() != 4 {
Expand Down Expand Up @@ -51,8 +58,13 @@ pub fn process_int_nums(
return Err(MiscError::RepeatedIdxIntNums);
}
}
let n_indices = if is_threefold {
intnum_idxpairs.iter().map(|p| p.1).max().unwrap()
} else {
intnum_dict.keys().map(|p| p.0).max().unwrap()
} + 1;

Ok((intnum_dict, intnum_idxpairs))
Ok((intnum_dict, intnum_idxpairs, n_indices))
}

#[cfg(test)]
Expand All @@ -68,14 +80,16 @@ mod tests {
-1, 3, 2;];
let result = process_int_nums(intnums.clone(), true);
assert!(result.is_ok());
let (intnum_dict, intnum_idxpairs) = result.unwrap();
let (intnum_dict, intnum_idxpairs, n_indices) = result.unwrap();
assert_eq!(intnum_dict.len(), 3);
assert_eq!(intnum_idxpairs.len(), 6);
assert_eq!(n_indices, 4);

let result = process_int_nums(intnums.clone(), false);
assert!(result.is_ok());
let (intnum_dict, intnum_idxpairs) = result.unwrap();
let (intnum_dict, intnum_idxpairs, n_indices) = result.unwrap();
assert_eq!(intnum_dict.len(), 3);
assert_eq!(intnum_idxpairs.len(), 3);
assert_eq!(n_indices, 1);
}
}

0 comments on commit 0ee8907

Please sign in to comment.