diff --git a/src/qdldl/qdldl.rs b/src/qdldl/qdldl.rs index d3fba18..7171efb 100644 --- a/src/qdldl/qdldl.rs +++ b/src/qdldl/qdldl.rs @@ -738,14 +738,14 @@ fn _invperm(p: &[usize]) -> Result, QDLDLError> { // in both cases for safety pub(crate) fn permute(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(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); } diff --git a/src/qdldl/test.rs b/src/qdldl/test.rs index c7d2ebc..8c21a78 100644 --- a/src/qdldl/test.rs +++ b/src/qdldl/test.rs @@ -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];