Skip to content

Commit 7801d26

Browse files
committed
Fix off-by-one in superb allocation for svd
valgrind reports errors in SVD. There is very little documentation on the 'superb' argument of *gesvd. Intel MKL documentation states that its size should be min(m, n) - 2. However, in the MKL examples min(m, n) - 1 is used: https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_dgesvd_row.c.htm Changing the size of superb to min(m, n) -1 resolved the memory error in valgrind.
1 parent 4614d0e commit 7801d26

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lapack_traits/svd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ macro_rules! impl_svd {
5050
(FlagSVD::No, 0, Vec::new())
5151
};
5252
let mut s = vec![Self::Real::zero(); k as usize];
53-
let mut superb = vec![Self::Real::zero(); (k - 2) as usize];
53+
let mut superb = vec![Self::Real::zero(); (k - 1) as usize];
5454
let info = $gesvd(
5555
l.lapacke_layout(),
5656
ju as u8,

0 commit comments

Comments
 (0)