Fix botched Search + Replace

This commit is contained in:
Violeta Hernández 2021-07-17 13:58:34 -05:00
parent 7e1b2f81b3
commit 4bd13a509a
7 changed files with 23 additions and 18 deletions

View File

@ -78,9 +78,11 @@ where
let lda = n as i32; let lda = n as i32;
let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; // IMPORTANT TODO: this is still UB.
let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() };
// TODO: Tap into the workspace. // TODO: Tap into the workspace.
let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() };
let mut info = 0; let mut info = 0;
let mut placeholder1 = [T::zero()]; let mut placeholder1 = [T::zero()];
@ -247,8 +249,8 @@ where
let lda = n as i32; let lda = n as i32;
let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() };
let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() };
let mut info = 0; let mut info = 0;
let mut placeholder1 = [T::zero()]; let mut placeholder1 = [T::zero()];
@ -291,7 +293,7 @@ where
); );
lapack_panic!(info); lapack_panic!(info);
let mut res = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; let mut res = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).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,8 +60,9 @@ where
"Unable to compute the hessenberg decomposition of an empty matrix." "Unable to compute the hessenberg decomposition of an empty matrix."
); );
// IMPORTANT TODO: this is still UB.
let mut tau = unsafe { let mut tau = unsafe {
Matrix::new_uninitialized_generic(nrows.sub(U1), U1).assume_init() Matrix::new_uninitialized_generic(nrows.sub(Const::<1>), Const::<1>).assume_init()
}; };
let mut info = 0; let mut info = 0;

View File

@ -66,7 +66,7 @@ where
let nrows = nrows.value() as i32; let nrows = nrows.value() as i32;
let ncols = ncols.value() as i32; let ncols = ncols.value() as i32;
let mut ipiv: OVector<i32, _> = Matrix::zeros_generic(min_nrows_ncols, U1); let mut ipiv: OVector<i32, _> = Matrix::zeros_generic(min_nrows_ncols, Const::<1>);
let mut info = 0; let mut info = 0;

View File

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

View File

@ -99,8 +99,9 @@ macro_rules! svd_impl(
let lda = nrows.value() as i32; let lda = nrows.value() as i32;
// IMPORTANT TODO: this is still UB.
let mut u = unsafe { Matrix::new_uninitialized_generic(nrows, nrows).assume_init() }; let mut u = unsafe { Matrix::new_uninitialized_generic(nrows, nrows).assume_init() };
let mut s = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1).assume_init() }; let mut s = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), Const::<1>).assume_init() };
let mut vt = unsafe { Matrix::new_uninitialized_generic(ncols, ncols).assume_init() }; let mut vt = unsafe { Matrix::new_uninitialized_generic(ncols, ncols).assume_init() };
let ldu = nrows.value(); let ldu = nrows.value();

View File

@ -93,9 +93,10 @@ where
let n = nrows.value(); let n = nrows.value();
let lda = n as i32; let lda = n as i32;
// IMPORTANT TODO: this is still UB.
let mut values = let mut values =
unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() };
let mut info = 0; let mut info = 0;
let lwork = T::xsyev_work_size(jobz, b'L', n as i32, m.as_mut_slice(), lda, &mut info); let lwork = T::xsyev_work_size(jobz, b'L', n as i32, m.as_mut_slice(), lda, &mut info);

View File

@ -180,11 +180,11 @@ macro_rules! generate_matrix_sanity_test {
// Test all fixed-size matrices with row/col dimensions up to 3 // Test all fixed-size matrices with row/col dimensions up to 3
generate_matrix_sanity_test!(test_matrix_u0_u0, Const::<0>, Const::<0>); generate_matrix_sanity_test!(test_matrix_u0_u0, Const::<0>, Const::<0>);
generate_matrix_sanity_test!(test_matrix_u1_u0, U1, Const::<0>); generate_matrix_sanity_test!(test_matrix_u1_u0, Const::<1>, Const::<0>);
generate_matrix_sanity_test!(test_matrix_u0_u1, Const::<0>, U1); generate_matrix_sanity_test!(test_matrix_u0_u1, Const::<0>, Const::<1>);
generate_matrix_sanity_test!(test_matrix_u1_u1, U1, U1); generate_matrix_sanity_test!(test_matrix_u1_u1, Const::<1>, Const::<1>);
generate_matrix_sanity_test!(test_matrix_u2_u1, Const::<2>, U1); generate_matrix_sanity_test!(test_matrix_u2_u1, Const::<2>, Const::<1>);
generate_matrix_sanity_test!(test_matrix_u1_u2, U1, Const::<2>); generate_matrix_sanity_test!(test_matrix_u1_u2, Const::<1>, Const::<2>);
generate_matrix_sanity_test!(test_matrix_u2_u2, Const::<2>, Const::<2>); generate_matrix_sanity_test!(test_matrix_u2_u2, Const::<2>, Const::<2>);
generate_matrix_sanity_test!(test_matrix_u3_u2, Const::<3>, Const::<2>); generate_matrix_sanity_test!(test_matrix_u3_u2, Const::<3>, Const::<2>);
generate_matrix_sanity_test!(test_matrix_u2_u3, Const::<2>, Const::<3>); generate_matrix_sanity_test!(test_matrix_u2_u3, Const::<2>, Const::<3>);