Skip to content

Commit

Permalink
fixes #125
Browse files Browse the repository at this point in the history
  • Loading branch information
goulart-paul committed Nov 26, 2024
1 parent 7036899 commit 5309422
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/qdldl/qdldl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,14 @@ fn _invperm(p: &[usize]) -> Result<Vec<usize>, QDLDLError> {
// in both cases for safety

pub(crate) fn permute<T: Copy>(x: &mut [T], b: &[T], p: &[usize]) {
debug_assert!(*p.iter().max().unwrap_or(&0) < x.len());
debug_assert!(p.is_empty() || *p.iter().max().unwrap() < x.len());
unsafe {
zip(p, x).for_each(|(p, x)| *x = *b.get_unchecked(*p));
}
}

pub(crate) fn ipermute<T: Copy>(x: &mut [T], b: &[T], p: &[usize]) {
debug_assert!(*p.iter().max().unwrap_or(&0) < x.len());
debug_assert!(p.is_empty() || *p.iter().max().unwrap() < x.len());
unsafe {
zip(p, b).for_each(|(p, b)| *x.get_unchecked_mut(*p) = *b);
}
Expand Down
2 changes: 1 addition & 1 deletion src/qdldl/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn test_invperm_bad_perm2() {

#[test]
fn test_permute() {
let perm = vec![3, 0, 2, 1]; //index too big
let perm = vec![3, 0, 2, 1];
let b = vec![1., 2., 3., 4.];
let mut x = vec![0.; 4];
let mut y = vec![0.; 4];
Expand Down

0 comments on commit 5309422

Please sign in to comment.