Got rid of the `unimplemented_or_uninitialized_generic` macro
This commit is contained in:
parent
0687318c7a
commit
fa1ed9683b
|
@ -140,6 +140,7 @@ impl ComplexHelper for Complex<f64> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is UB.
|
||||||
unsafe fn uninitialized_vec<T: Copy>(n: usize) -> Vec<T> {
|
unsafe fn uninitialized_vec<T: Copy>(n: usize) -> Vec<T> {
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
res.reserve_exact(n);
|
res.reserve_exact(n);
|
||||||
|
|
|
@ -25,14 +25,6 @@ use crate::base::{
|
||||||
ArrayStorage, Const, DefaultAllocator, Matrix, OMatrix, OVector, Scalar, Unit, Vector,
|
ArrayStorage, Const, DefaultAllocator, Matrix, OMatrix, OVector, Scalar, Unit, Vector,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// OBJECTIVE: GET RID OF THIS!
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! unimplemented_or_uninitialized_generic {
|
|
||||||
($nrows:expr, $ncols:expr) => {{
|
|
||||||
crate::base::Matrix::new_uninitialized_generic($nrows, $ncols)
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # Generic constructors
|
/// # Generic constructors
|
||||||
/// This set of matrix and vector construction functions are all generic
|
/// This set of matrix and vector construction functions are all generic
|
||||||
/// with-regard to the matrix dimensions. They all expect to be given
|
/// with-regard to the matrix dimensions. They all expect to be given
|
||||||
|
|
|
@ -279,7 +279,7 @@ where
|
||||||
CsMatrix {
|
CsMatrix {
|
||||||
data: CsVecStorage {
|
data: CsVecStorage {
|
||||||
shape: (nrows, ncols),
|
shape: (nrows, ncols),
|
||||||
p: OVector::zeros_generic(ncols, U1),
|
p: OVector::zeros_generic(ncols, Const::<1>),
|
||||||
i,
|
i,
|
||||||
vals,
|
vals,
|
||||||
},
|
},
|
||||||
|
@ -429,7 +429,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: CsStorage<T, R, C>> CsMatrix<T, R, C, S> {
|
||||||
|
|
||||||
let nvals = self.len();
|
let nvals = self.len();
|
||||||
let mut res = CsMatrix::new_uninitialized_generic(ncols, nrows, nvals);
|
let mut res = CsMatrix::new_uninitialized_generic(ncols, nrows, nvals);
|
||||||
let mut workspace = Vector::zeros_generic(nrows, U1);
|
let mut workspace = Vector::zeros_generic(nrows, Const::<1>);
|
||||||
|
|
||||||
// Compute p.
|
// Compute p.
|
||||||
for i in 0..nvals {
|
for i in 0..nvals {
|
||||||
|
@ -472,8 +472,7 @@ where
|
||||||
{
|
{
|
||||||
// Size = R
|
// Size = R
|
||||||
let nrows = self.data.shape().0;
|
let nrows = self.data.shape().0;
|
||||||
let mut workspace =
|
let mut workspace = Matrix::new_uninitialized_generic(nrows, Const::<1>);
|
||||||
unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, U1) };
|
|
||||||
self.sort_with_workspace(workspace.as_mut_slice());
|
self.sort_with_workspace(workspace.as_mut_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,8 @@ where
|
||||||
let (l, u) = Self::nonzero_pattern(m);
|
let (l, u) = Self::nonzero_pattern(m);
|
||||||
|
|
||||||
// Workspaces.
|
// Workspaces.
|
||||||
let work_x =
|
let work_x = Matrix::new_uninitialized_generic(m.data.shape().0, Const::<1>);
|
||||||
unsafe { crate::unimplemented_or_uninitialized_generic!(m.data.shape().0, U1) };
|
let work_c = Matrix::new_uninitialized_generic(m.data.shape().1, Const::<1>);
|
||||||
let work_c =
|
|
||||||
unsafe { crate::unimplemented_or_uninitialized_generic!(m.data.shape().1, U1) };
|
|
||||||
let mut original_p = m.data.p.as_slice().to_vec();
|
let mut original_p = m.data.p.as_slice().to_vec();
|
||||||
original_p.push(m.data.i.len());
|
original_p.push(m.data.i.len());
|
||||||
|
|
||||||
|
@ -294,8 +292,7 @@ where
|
||||||
let etree = Self::elimination_tree(m);
|
let etree = Self::elimination_tree(m);
|
||||||
let (nrows, ncols) = m.data.shape();
|
let (nrows, ncols) = m.data.shape();
|
||||||
let mut rows = Vec::with_capacity(m.len());
|
let mut rows = Vec::with_capacity(m.len());
|
||||||
let mut cols =
|
let mut cols = Matrix::new_uninitialized_generic(m.data.shape().0, Const::<1>);
|
||||||
unsafe { crate::unimplemented_or_uninitialized_generic!(m.data.shape().0, U1) };
|
|
||||||
let mut marks = Vec::new();
|
let mut marks = Vec::new();
|
||||||
|
|
||||||
// NOTE: the following will actually compute the non-zero pattern of
|
// NOTE: the following will actually compute the non-zero pattern of
|
||||||
|
|
|
@ -148,7 +148,7 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut res = CsMatrix::new_uninitialized_generic(nrows1, ncols2, self.len() + rhs.len());
|
let mut res = CsMatrix::new_uninitialized_generic(nrows1, ncols2, self.len() + rhs.len());
|
||||||
let mut workspace = OVector::<T, R1>::zeros_generic(nrows1, U1);
|
let mut workspace = OVector::<T, R1>::zeros_generic(nrows1, Const::<1>);
|
||||||
let mut nz = 0;
|
let mut nz = 0;
|
||||||
|
|
||||||
for j in 0..ncols2.value() {
|
for j in 0..ncols2.value() {
|
||||||
|
@ -241,9 +241,9 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut res = CsMatrix::new_uninitialized_generic(nrows1, ncols2, self.len() + rhs.len());
|
let mut res = CsMatrix::new_uninitialized_generic(nrows1, ncols2, self.len() + rhs.len());
|
||||||
let mut timestamps = OVector::zeros_generic(nrows1, U1);
|
let mut timestamps = OVector::zeros_generic(nrows1, Const::<1>);
|
||||||
let mut workspace =
|
let mut workspace =
|
||||||
unsafe { crate::unimplemented_or_uninitialized_generic!(nrows1, U1) };
|
Matrix::new_uninitialized_generic(nrows1, Const::<1>) ;
|
||||||
let mut nz = 0;
|
let mut nz = 0;
|
||||||
|
|
||||||
for j in 0..ncols2.value() {
|
for j in 0..ncols2.value() {
|
||||||
|
|
|
@ -152,8 +152,7 @@ impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S> {
|
||||||
self.lower_triangular_reach(b, &mut reach);
|
self.lower_triangular_reach(b, &mut reach);
|
||||||
// We sort the reach so the result matrix has sorted indices.
|
// We sort the reach so the result matrix has sorted indices.
|
||||||
reach.sort_unstable();
|
reach.sort_unstable();
|
||||||
let mut workspace =
|
let mut workspace = Matrix::new_uninitialized_generic(b.data.shape().0, Const::<1>);
|
||||||
unsafe { crate::unimplemented_or_uninitialized_generic!(b.data.shape().0, U1) };
|
|
||||||
|
|
||||||
for i in reach.iter().cloned() {
|
for i in reach.iter().cloned() {
|
||||||
workspace[i] = T::zero();
|
workspace[i] = T::zero();
|
||||||
|
@ -191,7 +190,7 @@ impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S> {
|
||||||
|
|
||||||
// Copy the result into a sparse vector.
|
// Copy the result into a sparse vector.
|
||||||
let mut result =
|
let mut result =
|
||||||
CsVector::new_uninitialized_generic(b.data.shape().0, U1, reach.len());
|
CsVector::new_uninitialized_generic(b.data.shape().0, Const::<1>, reach.len());
|
||||||
|
|
||||||
for (i, val) in reach.iter().zip(result.data.vals.iter_mut()) {
|
for (i, val) in reach.iter().zip(result.data.vals.iter_mut()) {
|
||||||
*val = workspace[*i];
|
*val = workspace[*i];
|
||||||
|
@ -255,7 +254,7 @@ impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S> {
|
||||||
S2: CsStorage<T, D2>,
|
S2: CsStorage<T, D2>,
|
||||||
DefaultAllocator: Allocator<bool, D>,
|
DefaultAllocator: Allocator<bool, D>,
|
||||||
{
|
{
|
||||||
let mut visited = OVector::repeat_generic(self.data.shape().1, U1, false);
|
let mut visited = OVector::repeat_generic(self.data.shape().1, Const::<1>, false);
|
||||||
let mut stack = Vec::new();
|
let mut stack = Vec::new();
|
||||||
|
|
||||||
for irow in b.data.column_row_indices(0) {
|
for irow in b.data.column_row_indices(0) {
|
||||||
|
|
|
@ -433,8 +433,8 @@ where
|
||||||
"Matrix meet/join error: mismatched dimensions."
|
"Matrix meet/join error: mismatched dimensions."
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut mres = unsafe { crate::unimplemented_or_uninitialized_generic!(shape.0, shape.1) };
|
let mut mres = Matrix::new_uninitialized_generic(shape.0, shape.1);
|
||||||
let mut jres = unsafe { crate::unimplemented_or_uninitialized_generic!(shape.0, shape.1) };
|
let mut jres = Matrix::new_uninitialized_generic(shape.0, shape.1);
|
||||||
|
|
||||||
for i in 0..shape.0.value() * shape.1.value() {
|
for i in 0..shape.0.value() * shape.1.value() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Reference in New Issue