diff --git a/src/base/blas.rs b/src/base/blas.rs index 111c6dd1..92a43a38 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -1328,7 +1328,8 @@ where ShapeConstraint: DimEq + DimEq + DimEq, DefaultAllocator: Allocator, { - let mut work = unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, U1) }; + let mut work = + unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, U1) }; self.quadform_tr_with_workspace(&mut work, alpha, lhs, mid, beta) } @@ -1421,7 +1422,8 @@ where ShapeConstraint: DimEq + DimEq + AreMultipliable, DefaultAllocator: Allocator, { - let mut work = unsafe { crate::unimplemented_or_uninitialized_generic!(mid.data.shape().0, U1) }; + let mut work = + unsafe { crate::unimplemented_or_uninitialized_generic!(mid.data.shape().0, U1) }; self.quadform_with_workspace(&mut work, alpha, mid, rhs, beta) } } diff --git a/src/base/conversion.rs b/src/base/conversion.rs index e7a52d1f..b852ff59 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -50,7 +50,8 @@ where let nrows2 = R2::from_usize(nrows); let ncols2 = C2::from_usize(ncols); - let mut res: MatrixMN = unsafe { crate::unimplemented_or_uninitialized_generic!(nrows2, ncols2) }; + let mut res: MatrixMN = + unsafe { crate::unimplemented_or_uninitialized_generic!(nrows2, ncols2) }; for i in 0..nrows { for j in 0..ncols { unsafe { diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index 64b60a66..81ed1f53 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -55,9 +55,9 @@ where ncols: C, iter: I, ) -> Self::Buffer { - #[cfg(feature="no_unsound_assume_init")] + #[cfg(feature = "no_unsound_assume_init")] let mut res: Self::Buffer = unimplemented!(); - #[cfg(not(feature="no_unsound_assume_init"))] + #[cfg(not(feature = "no_unsound_assume_init"))] let mut res = unsafe { Self::allocate_uninitialized(nrows, ncols).assume_init() }; let mut count = 0; @@ -158,10 +158,11 @@ where cto: CTo, buf: >::Buffer, ) -> ArrayStorage { - #[cfg(feature="no_unsound_assume_init")] + #[cfg(feature = "no_unsound_assume_init")] let mut res: ArrayStorage = unimplemented!(); - #[cfg(not(feature="no_unsound_assume_init"))] - let mut res = >::allocate_uninitialized(rto, cto).assume_init(); + #[cfg(not(feature = "no_unsound_assume_init"))] + let mut res = + >::allocate_uninitialized(rto, cto).assume_init(); let (rfrom, cfrom) = buf.shape(); @@ -189,10 +190,11 @@ where cto: CTo, buf: ArrayStorage, ) -> VecStorage { - #[cfg(feature="no_unsound_assume_init")] + #[cfg(feature = "no_unsound_assume_init")] let mut res: VecStorage = unimplemented!(); - #[cfg(not(feature="no_unsound_assume_init"))] - let mut res = >::allocate_uninitialized(rto, cto).assume_init(); + #[cfg(not(feature = "no_unsound_assume_init"))] + let mut res = + >::allocate_uninitialized(rto, cto).assume_init(); let (rfrom, cfrom) = buf.shape(); @@ -220,10 +222,11 @@ where cto: Dynamic, buf: ArrayStorage, ) -> VecStorage { - #[cfg(feature="no_unsound_assume_init")] + #[cfg(feature = "no_unsound_assume_init")] let mut res: VecStorage = unimplemented!(); - #[cfg(not(feature="no_unsound_assume_init"))] - let mut res = >::allocate_uninitialized(rto, cto).assume_init(); + #[cfg(not(feature = "no_unsound_assume_init"))] + let mut res = + >::allocate_uninitialized(rto, cto).assume_init(); let (rfrom, cfrom) = buf.shape(); diff --git a/src/base/edition.rs b/src/base/edition.rs index c2a0595e..9d8606af 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -54,7 +54,9 @@ impl> Matrix { { let irows = irows.into_iter(); let ncols = self.data.shape().1; - let mut res = unsafe { crate::unimplemented_or_uninitialized_generic!(Dynamic::new(irows.len()), ncols) }; + let mut res = unsafe { + crate::unimplemented_or_uninitialized_generic!(Dynamic::new(irows.len()), ncols) + }; // First, check that all the indices from irows are valid. // This will allow us to use unchecked access in the inner loop. @@ -88,8 +90,9 @@ impl> Matrix { { let icols = icols.into_iter(); let nrows = self.data.shape().0; - let mut res = - unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, Dynamic::new(icols.len())) }; + let mut res = unsafe { + crate::unimplemented_or_uninitialized_generic!(nrows, Dynamic::new(icols.len())) + }; for (destination, source) in icols.enumerate() { res.column_mut(destination).copy_from(&self.column(*source)) @@ -895,7 +898,9 @@ impl DMatrix { where DefaultAllocator: Reallocator, { - let placeholder = unsafe { crate::unimplemented_or_uninitialized_generic!(Dynamic::new(0), Dynamic::new(0)) }; + let placeholder = unsafe { + crate::unimplemented_or_uninitialized_generic!(Dynamic::new(0), Dynamic::new(0)) + }; let old = mem::replace(self, placeholder); let new = old.resize(new_nrows, new_ncols, val); let _ = mem::replace(self, new); @@ -918,7 +923,9 @@ where where DefaultAllocator: Reallocator, { - let placeholder = unsafe { crate::unimplemented_or_uninitialized_generic!(Dynamic::new(0), self.data.shape().1) }; + let placeholder = unsafe { + crate::unimplemented_or_uninitialized_generic!(Dynamic::new(0), self.data.shape().1) + }; let old = mem::replace(self, placeholder); let new = old.resize_vertically(new_nrows, val); let _ = mem::replace(self, new); @@ -941,7 +948,9 @@ where where DefaultAllocator: Reallocator, { - let placeholder = unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, Dynamic::new(0)) }; + let placeholder = unsafe { + crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, Dynamic::new(0)) + }; let old = mem::replace(self, placeholder); let new = old.resize_horizontally(new_ncols, val); let _ = mem::replace(self, new); diff --git a/src/base/matrix.rs b/src/base/matrix.rs index b5fc169e..889c1ecd 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -300,8 +300,12 @@ impl> Matrix { /// Creates a new uninitialized matrix with the given uninitialized data pub unsafe fn from_uninitialized_data(data: mem::MaybeUninit) -> mem::MaybeUninit { - let res: Matrix> = Matrix { data, _phantoms: PhantomData }; - let res: mem::MaybeUninit>> = mem::MaybeUninit::new(res); + let res: Matrix> = Matrix { + data, + _phantoms: PhantomData, + }; + let res: mem::MaybeUninit>> = + mem::MaybeUninit::new(res); // safety: since we wrap the inner MaybeUninit in an outer MaybeUninit above, the fact that the `data` field is partially-uninitialized is still opaque. // with s/transmute_copy/transmute/, rustc claims that `MaybeUninit>>` may be of a different size from `MaybeUninit>` // but MaybeUninit's documentation says "MaybeUninit is guaranteed to have the same size, alignment, and ABI as T", which implies those types should be the same size @@ -507,7 +511,8 @@ impl> Matrix { let nrows: SameShapeR = Dim::from_usize(nrows); let ncols: SameShapeC = Dim::from_usize(ncols); - let mut res: MatrixSum = unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; + let mut res: MatrixSum = + unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; // TODO: use copy_from for j in 0..res.ncols() { @@ -574,7 +579,8 @@ impl> Matrix { { let (nrows, ncols) = self.data.shape(); - let mut res: MatrixMN = unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; + let mut res: MatrixMN = + unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; for j in 0..ncols.value() { for i in 0..nrows.value() { @@ -618,7 +624,8 @@ impl> Matrix { { let (nrows, ncols) = self.data.shape(); - let mut res: MatrixMN = unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; + let mut res: MatrixMN = + unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; for j in 0..ncols.value() { for i in 0..nrows.value() { @@ -645,7 +652,8 @@ impl> Matrix { { let (nrows, ncols) = self.data.shape(); - let mut res: MatrixMN = unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; + let mut res: MatrixMN = + unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; assert_eq!( (nrows.value(), ncols.value()), @@ -686,7 +694,8 @@ impl> Matrix { { let (nrows, ncols) = self.data.shape(); - let mut res: MatrixMN = unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; + let mut res: MatrixMN = + unsafe { crate::unimplemented_or_uninitialized_generic!(nrows, ncols) }; assert_eq!( (nrows.value(), ncols.value()), @@ -1180,7 +1189,8 @@ impl> Matrix = crate::unimplemented_or_uninitialized_generic!(ncols, nrows); + let mut res: MatrixMN<_, C, R> = + crate::unimplemented_or_uninitialized_generic!(ncols, nrows); self.adjoint_to(&mut res); res @@ -1321,7 +1331,8 @@ impl> SquareMatrix { ); let dim = self.data.shape().0; - let mut res: VectorN = unsafe { crate::unimplemented_or_uninitialized_generic!(dim, U1) }; + let mut res: VectorN = + unsafe { crate::unimplemented_or_uninitialized_generic!(dim, U1) }; for i in 0..dim.value() { unsafe { @@ -1448,7 +1459,8 @@ impl, S: Storage> Vector { { let len = self.len(); let hnrows = DimSum::::from_usize(len + 1); - let mut res: VectorN:: = unsafe { crate::unimplemented_or_uninitialized_generic!(hnrows, U1) }; + let mut res: VectorN = + unsafe { crate::unimplemented_or_uninitialized_generic!(hnrows, U1) }; res.generic_slice_mut((0, 0), self.data.shape()) .copy_from(self); res[(len, 0)] = element; @@ -1793,7 +1805,8 @@ impl::from_usize(3); let ncols = SameShapeC::::from_usize(1); - let mut res: MatrixCross = crate::unimplemented_or_uninitialized_generic!(nrows, ncols); + let mut res: MatrixCross = + crate::unimplemented_or_uninitialized_generic!(nrows, ncols); let ax = self.get_unchecked((0, 0)); let ay = self.get_unchecked((1, 0)); @@ -1817,7 +1830,8 @@ impl::from_usize(1); let ncols = SameShapeC::::from_usize(3); - let mut res: MatrixCross = crate::unimplemented_or_uninitialized_generic!(nrows, ncols); + let mut res: MatrixCross = + crate::unimplemented_or_uninitialized_generic!(nrows, ncols); let ax = self.get_unchecked((0, 0)); let ay = self.get_unchecked((0, 1)); diff --git a/src/base/mod.rs b/src/base/mod.rs index abe2fd48..9f08572f 100644 --- a/src/base/mod.rs +++ b/src/base/mod.rs @@ -15,7 +15,8 @@ mod alias_slice; mod array_storage; mod cg; mod componentwise; -#[macro_use] mod construction; +#[macro_use] +mod construction; mod construction_slice; mod conversion; mod edition; diff --git a/src/base/ops.rs b/src/base/ops.rs index 93ca3b8e..73f18a8c 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -573,7 +573,9 @@ where #[inline] fn mul(self, rhs: &'b Matrix) -> Self::Output { - let mut res = unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, rhs.data.shape().1) }; + let mut res = unsafe { + crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, rhs.data.shape().1) + }; self.mul_to(rhs, &mut res); res } @@ -682,7 +684,9 @@ where DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { - let mut res = unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().1, rhs.data.shape().1) }; + let mut res = unsafe { + crate::unimplemented_or_uninitialized_generic!(self.data.shape().1, rhs.data.shape().1) + }; self.tr_mul_to(rhs, &mut res); res @@ -697,7 +701,9 @@ where DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { - let mut res = unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().1, rhs.data.shape().1) }; + let mut res = unsafe { + crate::unimplemented_or_uninitialized_generic!(self.data.shape().1, rhs.data.shape().1) + }; self.ad_mul_to(rhs, &mut res); res @@ -811,7 +817,9 @@ where let (nrows1, ncols1) = self.data.shape(); let (nrows2, ncols2) = rhs.data.shape(); - let mut res = unsafe { crate::unimplemented_or_uninitialized_generic!(nrows1.mul(nrows2), ncols1.mul(ncols2)) }; + let mut res = unsafe { + crate::unimplemented_or_uninitialized_generic!(nrows1.mul(nrows2), ncols1.mul(ncols2)) + }; { let mut data_res = res.data.ptr_mut(); diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 7ee5a9c9..811b508f 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -17,7 +17,8 @@ impl> Matrix { DefaultAllocator: Allocator, { let ncols = self.data.shape().1; - let mut res: RowVectorN = unsafe { crate::unimplemented_or_uninitialized_generic!(U1, ncols) }; + let mut res: RowVectorN = + unsafe { crate::unimplemented_or_uninitialized_generic!(U1, ncols) }; for i in 0..ncols.value() { // TODO: avoid bound checking of column. @@ -42,7 +43,8 @@ impl> Matrix { DefaultAllocator: Allocator, { let ncols = self.data.shape().1; - let mut res: VectorN = unsafe { crate::unimplemented_or_uninitialized_generic!(ncols, U1) }; + let mut res: VectorN = + unsafe { crate::unimplemented_or_uninitialized_generic!(ncols, U1) }; for i in 0..ncols.value() { // TODO: avoid bound checking of column. diff --git a/src/geometry/point.rs b/src/geometry/point.rs index d668e804..f5c8d31f 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -181,7 +181,12 @@ where D: DimNameAdd, DefaultAllocator: Allocator>, { - let mut res = unsafe { crate::unimplemented_or_uninitialized_generic!( as DimName>::name(), U1) }; + let mut res = unsafe { + crate::unimplemented_or_uninitialized_generic!( + as DimName>::name(), + U1 + ) + }; res.fixed_slice_mut::(0, 0).copy_from(&self.coords); res[(D::dim(), 0)] = N::one(); diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 48c4a71c..c21680a9 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -24,7 +24,10 @@ where /// Creates a new point with uninitialized coordinates. #[inline] pub unsafe fn new_uninitialized() -> Self { - Self::from(crate::unimplemented_or_uninitialized_generic!(D::name(), U1)) + Self::from(crate::unimplemented_or_uninitialized_generic!( + D::name(), + U1 + )) } /// Creates a new point with all coordinates equal to zero. diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index 0202eb68..33fc81e6 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -81,7 +81,8 @@ where "Cannot compute the bidiagonalization of an empty matrix." ); - let mut diagonal = unsafe { crate::unimplemented_or_uninitialized_generic!(min_nrows_ncols, U1) }; + let mut diagonal = + unsafe { crate::unimplemented_or_uninitialized_generic!(min_nrows_ncols, U1) }; let mut off_diagonal = unsafe { crate::unimplemented_or_uninitialized_generic!(min_nrows_ncols.sub(U1), U1) }; let mut axis_packed = unsafe { crate::unimplemented_or_uninitialized_generic!(ncols, U1) }; @@ -239,7 +240,8 @@ where let min_nrows_ncols = nrows.min(ncols); let mut res = Matrix::identity_generic(min_nrows_ncols, ncols); - let mut work = unsafe { crate::unimplemented_or_uninitialized_generic!(min_nrows_ncols, U1) }; + let mut work = + unsafe { crate::unimplemented_or_uninitialized_generic!(min_nrows_ncols, U1) }; let mut axis_packed = unsafe { crate::unimplemented_or_uninitialized_generic!(ncols, U1) }; let shift = self.axis_shift().1; diff --git a/src/linalg/hessenberg.rs b/src/linalg/hessenberg.rs index c6103ffd..ac3e82b8 100644 --- a/src/linalg/hessenberg.rs +++ b/src/linalg/hessenberg.rs @@ -48,7 +48,8 @@ where { /// Computes the Hessenberg decomposition using householder reflections. pub fn new(hess: MatrixN) -> Self { - let mut work = unsafe { crate::unimplemented_or_uninitialized_generic!(hess.data.shape().0, U1) }; + let mut work = + unsafe { crate::unimplemented_or_uninitialized_generic!(hess.data.shape().0, U1) }; Self::new_with_workspace(hess, &mut work) } @@ -74,7 +75,8 @@ where "Hessenberg: invalid workspace size." ); - let mut subdiag = unsafe { crate::unimplemented_or_uninitialized_generic!(dim.sub(U1), U1) }; + let mut subdiag = + unsafe { crate::unimplemented_or_uninitialized_generic!(dim.sub(U1), U1) }; if dim.value() == 0 { return Hessenberg { hess, subdiag }; diff --git a/src/linalg/qr.rs b/src/linalg/qr.rs index 063cad0d..b9cec96a 100644 --- a/src/linalg/qr.rs +++ b/src/linalg/qr.rs @@ -54,7 +54,8 @@ where let (nrows, ncols) = matrix.data.shape(); let min_nrows_ncols = nrows.min(ncols); - let mut diag = unsafe { crate::unimplemented_or_uninitialized_generic!(min_nrows_ncols, U1) }; + let mut diag = + unsafe { crate::unimplemented_or_uninitialized_generic!(min_nrows_ncols, U1) }; if min_nrows_ncols.value() == 0 { return QR { qr: matrix, diag }; diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index 820c0e21..4b89567b 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -71,7 +71,8 @@ where /// number of iteration is exceeded, `None` is returned. If `niter == 0`, then the algorithm /// continues indefinitely until convergence. pub fn try_new(m: MatrixN, eps: N::RealField, max_niter: usize) -> Option { - let mut work = unsafe { crate::unimplemented_or_uninitialized_generic!(m.data.shape().0, U1) }; + let mut work = + unsafe { crate::unimplemented_or_uninitialized_generic!(m.data.shape().0, U1) }; Self::do_decompose(m, &mut work, eps, max_niter, true) .map(|(q, t)| Schur { q: q.unwrap(), t }) @@ -378,7 +379,8 @@ where /// /// Return `None` if some eigenvalues are complex. pub fn eigenvalues(&self) -> Option> { - let mut out = unsafe { crate::unimplemented_or_uninitialized_generic!(self.t.data.shape().0, U1) }; + let mut out = + unsafe { crate::unimplemented_or_uninitialized_generic!(self.t.data.shape().0, U1) }; if Self::do_eigenvalues(&self.t, &mut out) { Some(out) } else { @@ -392,7 +394,8 @@ where N: RealField, DefaultAllocator: Allocator, D>, { - let mut out = unsafe { crate::unimplemented_or_uninitialized_generic!(self.t.data.shape().0, U1) }; + let mut out = + unsafe { crate::unimplemented_or_uninitialized_generic!(self.t.data.shape().0, U1) }; Self::do_complex_eigenvalues(&self.t, &mut out); out } @@ -503,7 +506,8 @@ where "Unable to compute eigenvalues of a non-square matrix." ); - let mut work = unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, U1) }; + let mut work = + unsafe { crate::unimplemented_or_uninitialized_generic!(self.data.shape().0, U1) }; // Special case for 2x2 matrices. if self.nrows() == 2 { diff --git a/src/linalg/symmetric_tridiagonal.rs b/src/linalg/symmetric_tridiagonal.rs index ba47724e..c05b5558 100644 --- a/src/linalg/symmetric_tridiagonal.rs +++ b/src/linalg/symmetric_tridiagonal.rs @@ -61,7 +61,8 @@ where "Unable to compute the symmetric tridiagonal decomposition of an empty matrix." ); - let mut off_diagonal = unsafe { crate::unimplemented_or_uninitialized_generic!(dim.sub(U1), U1) }; + let mut off_diagonal = + unsafe { crate::unimplemented_or_uninitialized_generic!(dim.sub(U1), U1) }; let mut p = unsafe { crate::unimplemented_or_uninitialized_generic!(dim.sub(U1), U1) }; for i in 0..dim.value() - 1 {