Fix nalgebra-lapack.

Since nalgebra-lapack can only be used with f32 and f64, it is OK to just call `.assume_init()`.
This commit is contained in:
Crozet Sébastien 2021-02-25 15:07:15 +01:00
parent 162a7ef09c
commit 5225456883
6 changed files with 25 additions and 19 deletions

View File

@ -78,9 +78,9 @@ where
let lda = n as i32; let lda = n as i32;
let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
// TODO: Tap into the workspace. // TODO: Tap into the workspace.
let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
let mut info = 0; let mut info = 0;
let mut placeholder1 = [N::zero()]; let mut placeholder1 = [N::zero()];
@ -107,8 +107,10 @@ where
match (left_eigenvectors, eigenvectors) { match (left_eigenvectors, eigenvectors) {
(true, true) => { (true, true) => {
let mut vl = unsafe { Matrix::new_uninitialized_generic(nrows, ncols) }; let mut vl =
let mut vr = unsafe { Matrix::new_uninitialized_generic(nrows, ncols) }; unsafe { Matrix::new_uninitialized_generic(nrows, ncols).assume_init() };
let mut vr =
unsafe { Matrix::new_uninitialized_generic(nrows, ncols).assume_init() };
N::xgeev( N::xgeev(
ljob, ljob,
@ -137,7 +139,8 @@ where
} }
} }
(true, false) => { (true, false) => {
let mut vl = unsafe { Matrix::new_uninitialized_generic(nrows, ncols) }; let mut vl =
unsafe { Matrix::new_uninitialized_generic(nrows, ncols).assume_init() };
N::xgeev( N::xgeev(
ljob, ljob,
@ -166,7 +169,8 @@ where
} }
} }
(false, true) => { (false, true) => {
let mut vr = unsafe { Matrix::new_uninitialized_generic(nrows, ncols) }; let mut vr =
unsafe { Matrix::new_uninitialized_generic(nrows, ncols).assume_init() };
N::xgeev( N::xgeev(
ljob, ljob,
@ -243,8 +247,8 @@ where
let lda = n as i32; let lda = n as i32;
let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
let mut info = 0; let mut info = 0;
let mut placeholder1 = [N::zero()]; let mut placeholder1 = [N::zero()];
@ -287,7 +291,7 @@ where
); );
lapack_panic!(info); lapack_panic!(info);
let mut res = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut res = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
for i in 0..res.len() { for i in 0..res.len() {
res[i] = Complex::new(wr[i], wi[i]); res[i] = Complex::new(wr[i], wi[i]);

View File

@ -60,7 +60,7 @@ where
"Unable to compute the hessenberg decomposition of an empty matrix." "Unable to compute the hessenberg decomposition of an empty matrix."
); );
let mut tau = unsafe { Matrix::new_uninitialized_generic(nrows.sub(U1), U1) }; let mut tau = unsafe { Matrix::new_uninitialized_generic(nrows.sub(U1), U1).assume_init() };
let mut info = 0; let mut info = 0;
let lwork = let lwork =

View File

@ -57,7 +57,8 @@ where
let (nrows, ncols) = m.data.shape(); let (nrows, ncols) = m.data.shape();
let mut info = 0; let mut info = 0;
let mut tau = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1) }; let mut tau =
unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1).assume_init() };
if nrows.value() == 0 || ncols.value() == 0 { if nrows.value() == 0 || ncols.value() == 0 {
return Self { qr: m, tau: tau }; return Self { qr: m, tau: tau };

View File

@ -78,9 +78,9 @@ where
let mut info = 0; let mut info = 0;
let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
let mut q = unsafe { Matrix::new_uninitialized_generic(nrows, ncols) }; let mut q = unsafe { Matrix::new_uninitialized_generic(nrows, ncols).assume_init() };
// Placeholders: // Placeholders:
let mut bwork = [0i32]; let mut bwork = [0i32];
let mut unused = 0; let mut unused = 0;
@ -151,7 +151,8 @@ where
where where
DefaultAllocator: Allocator<Complex<N>, D>, DefaultAllocator: Allocator<Complex<N>, D>,
{ {
let mut out = unsafe { VectorN::new_uninitialized_generic(self.t.data.shape().0, U1) }; let mut out =
unsafe { VectorN::new_uninitialized_generic(self.t.data.shape().0, U1).assume_init() };
for i in 0..out.len() { for i in 0..out.len() {
out[i] = Complex::new(self.re[i], self.im[i]) out[i] = Complex::new(self.re[i], self.im[i])

View File

@ -99,9 +99,9 @@ macro_rules! svd_impl(
let lda = nrows.value() as i32; let lda = nrows.value() as i32;
let mut u = unsafe { Matrix::new_uninitialized_generic(nrows, nrows) }; let mut u = unsafe { Matrix::new_uninitialized_generic(nrows, nrows).assume_init() };
let mut s = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1) }; let mut s = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1).assume_init() };
let mut vt = unsafe { Matrix::new_uninitialized_generic(ncols, ncols) }; let mut vt = unsafe { Matrix::new_uninitialized_generic(ncols, ncols).assume_init() };
let ldu = nrows.value(); let ldu = nrows.value();
let ldvt = ncols.value(); let ldvt = ncols.value();

View File

@ -94,7 +94,7 @@ where
let lda = n as i32; let lda = n as i32;
let mut values = unsafe { Matrix::new_uninitialized_generic(nrows, U1) }; let mut values = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() };
let mut info = 0; let mut info = 0;
let lwork = N::xsyev_work_size(jobz, b'L', n as i32, m.as_mut_slice(), lda, &mut info); let lwork = N::xsyev_work_size(jobz, b'L', n as i32, m.as_mut_slice(), lda, &mut info);