diff --git a/src/base/blas.rs b/src/base/blas.rs index 5f51cea9..9d9dd2bd 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -393,7 +393,7 @@ where let col2 = a.column(0); let val = unsafe { x.vget_unchecked(0).clone() }; self.axpy(alpha.clone() * val, &col2, beta); - self[0] += alpha.clone() * dot(&a.slice_range(1.., 0), &x.rows_range(1..)); + self[0] += alpha.clone() * dot(&a.view_range(1.., 0), &x.rows_range(1..)); for j in 1..dim2 { let col2 = a.column(j); @@ -892,7 +892,7 @@ where let val = unsafe { conjugate(y.vget_unchecked(j).clone()) }; let subdim = Dynamic::new(dim1 - j); // TODO: avoid bound checks. - self.generic_slice_mut((j, j), (subdim, Const::<1>)).axpy( + self.generic_view_mut((j, j), (subdim, Const::<1>)).axpy( alpha.clone() * val, &x.rows_range(j..), beta.clone(), diff --git a/src/base/cg.rs b/src/base/cg.rs index ef3ad5b5..586c923e 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -59,7 +59,7 @@ where SB: Storage>, { let mut res = Self::identity(); - res.generic_slice_mut( + res.generic_view_mut( (0, D::dim() - 1), (DimNameDiff::::name(), Const::<1>), ) @@ -382,19 +382,19 @@ impl>, { let scale = self - .generic_slice( + .generic_view( (D::dim() - 1, 0), (Const::<1>, DimNameDiff::::name()), ) .tr_dot(shift); - let post_translation = self.generic_slice( + let post_translation = self.generic_view( (0, 0), (DimNameDiff::::name(), DimNameDiff::::name()), ) * shift; self[(D::dim() - 1, D::dim() - 1)] += scale; - let mut translation = self.generic_slice_mut( + let mut translation = self.generic_view_mut( (0, D::dim() - 1), (DimNameDiff::::name(), Const::<1>), ); @@ -415,11 +415,11 @@ where &self, v: &OVector>, ) -> OVector> { - let transform = self.generic_slice( + let transform = self.generic_view( (0, 0), (DimNameDiff::::name(), DimNameDiff::::name()), ); - let normalizer = self.generic_slice( + let normalizer = self.generic_view( (D::dim() - 1, 0), (Const::<1>, DimNameDiff::::name()), ); @@ -437,9 +437,9 @@ impl, Const<3>>> SquareMatrix, /// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates. #[inline] pub fn transform_point(&self, pt: &Point) -> Point { - let transform = self.fixed_slice::<2, 2>(0, 0); - let translation = self.fixed_slice::<2, 1>(0, 2); - let normalizer = self.fixed_slice::<1, 2>(2, 0); + let transform = self.fixed_view::<2, 2>(0, 0); + let translation = self.fixed_view::<2, 1>(0, 2); + let normalizer = self.fixed_view::<1, 2>(2, 0); let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((2, 2)).clone() }; if !n.is_zero() { @@ -454,9 +454,9 @@ impl, Const<4>>> SquareMatrix, /// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates. #[inline] pub fn transform_point(&self, pt: &Point) -> Point { - let transform = self.fixed_slice::<3, 3>(0, 0); - let translation = self.fixed_slice::<3, 1>(0, 3); - let normalizer = self.fixed_slice::<1, 3>(3, 0); + let transform = self.fixed_view::<3, 3>(0, 0); + let translation = self.fixed_view::<3, 1>(0, 3); + let normalizer = self.fixed_view::<1, 3>(3, 0); let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((3, 3)).clone() }; if !n.is_zero() { diff --git a/src/base/edition.rs b/src/base/edition.rs index 760b3950..104bd7fb 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -938,7 +938,7 @@ impl> Matrix { } if new_nrows.value() > nrows { - res.slice_range_mut(nrows.., ..cmp::min(ncols, new_ncols.value())) + res.view_range_mut(nrows.., ..cmp::min(ncols, new_ncols.value())) .fill_with(|| MaybeUninit::new(val.clone())); } diff --git a/src/base/matrix.rs b/src/base/matrix.rs index ae2f51e9..a263d761 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -446,7 +446,7 @@ impl> Matrix { /// ``` /// # use nalgebra::DMatrix; /// let mat = DMatrix::::zeros(10, 10); - /// let slice = mat.slice_with_steps((0, 0), (5, 3), (1, 2)); + /// let view = mat.view_with_steps((0, 0), (5, 3), (1, 2)); /// // The column strides is the number of steps (here 2) multiplied by the corresponding dimension. /// assert_eq!(mat.strides(), (1, 10)); /// ``` @@ -1633,7 +1633,7 @@ impl + IsNotStaticOne, S: RawStorage::from_usize(self.nrows() + 1); let mut res = OMatrix::identity_generic(dim, dim); - res.generic_slice_mut::((0, 0), self.shape_generic()) + res.generic_view_mut::((0, 0), self.shape_generic()) .copy_from(self); res } @@ -1661,7 +1661,7 @@ impl, S: RawStorage> Vector { { if v[v.len() - 1].is_zero() { let nrows = D::from_usize(v.len() - 1); - Some(v.generic_slice((0, 0), (nrows, Const::<1>)).into_owned()) + Some(v.generic_view((0, 0), (nrows, Const::<1>)).into_owned()) } else { None } @@ -1681,7 +1681,7 @@ impl, S: RawStorage> Vector { let mut res = Matrix::uninit(hnrows, Const::<1>); // This is basically a copy_from except that we warp the copied // values into MaybeUninit. - res.generic_slice_mut((0, 0), self.shape_generic()) + res.generic_view_mut((0, 0), self.shape_generic()) .zip_apply(self, |out, e| *out = MaybeUninit::new(e)); res[(len, 0)] = MaybeUninit::new(element); diff --git a/src/base/matrix_view.rs b/src/base/matrix_view.rs index d37346a6..0580546e 100644 --- a/src/base/matrix_view.rs +++ b/src/base/matrix_view.rs @@ -324,7 +324,7 @@ macro_rules! matrix_view_impl ( /// Returns a view containing the `n` first elements of the i-th row of this matrix. #[inline] pub fn $row_part($me: $Me, i: usize, n: usize) -> $MatrixView<'_, T, U1, Dynamic, S::RStride, S::CStride> { - $me.$generic_slice((i, 0), (Const::<1>, Dynamic::new(n))) + $me.$generic_view((i, 0), (Const::<1>, Dynamic::new(n))) } /// Extracts from this matrix a set of consecutive rows. @@ -961,7 +961,7 @@ impl> Matrix { ColRange: SliceRange, { let (nrows, ncols) = self.shape_generic(); - self.generic_slice( + self.generic_view( (rows.begin(nrows), cols.begin(ncols)), (rows.size(nrows), cols.size(ncols)), ) diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index d245c99b..67660800 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -428,7 +428,7 @@ impl Isometry { DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { let mut res: OMatrix = crate::convert_ref(&self.rotation); - res.fixed_slice_mut::(0, D) + res.fixed_view_mut::(0, D) .copy_from(&self.translation.vector); res diff --git a/src/geometry/isometry_conversion.rs b/src/geometry/isometry_conversion.rs index 627ea3ee..06507631 100644 --- a/src/geometry/isometry_conversion.rs +++ b/src/geometry/isometry_conversion.rs @@ -153,8 +153,8 @@ where #[inline] fn is_in_subset(m: &OMatrix, U1>, DimNameSum, U1>>) -> bool { - let rot = m.fixed_slice::(0, 0); - let bottom = m.fixed_slice::<1, D>(D, 0); + let rot = m.fixed_view::(0, 0); + let bottom = m.fixed_view::<1, D>(D, 0); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && @@ -168,7 +168,7 @@ where fn from_superset_unchecked( m: &OMatrix, U1>, DimNameSum, U1>>, ) -> Self { - let t = m.fixed_slice::(0, D).into_owned(); + let t = m.fixed_view::(0, D).into_owned(); let t = Translation { vector: crate::convert_unchecked(t), }; diff --git a/src/geometry/point.rs b/src/geometry/point.rs index e9a21439..3dd54b98 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -207,7 +207,7 @@ where let mut res = crate::Matrix::uninit(DimNameSum::::name(), Const::<1>); // This is basically a copy_from except that we warp the copied // values into MaybeUninit. - res.generic_slice_mut((0, 0), self.coords.shape_generic()) + res.generic_view_mut((0, 0), self.coords.shape_generic()) .zip_apply(&self.coords, |out, e| *out = MaybeUninit::new(e)); res[(len, 0)] = MaybeUninit::new(T::one()); diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 598cf4ed..04228cd2 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -113,7 +113,7 @@ where DefaultAllocator: Allocator>, { if !v[D::dim()].is_zero() { - let coords = v.generic_slice((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone(); + let coords = v.generic_view((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone(); Some(Self::from(coords)) } else { None diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index ce1bd930..81870379 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -66,7 +66,7 @@ where #[inline] fn from_superset_unchecked(v: &OVector>) -> Self { - let coords = v.generic_slice((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone(); + let coords = v.generic_view((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone(); Self { coords: crate::convert_unchecked(coords), } diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 4a71da0f..79f14eda 100755 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -261,7 +261,7 @@ impl Rotation { // adding the additional traits `DimAdd` and `IsNotStaticOne`. Maybe // these things will get nicer once specialization lands in Rust. let mut res = OMatrix::, U1>, DimNameSum, U1>>::identity(); - res.fixed_slice_mut::(0, 0).copy_from(&self.matrix); + res.fixed_view_mut::(0, 0).copy_from(&self.matrix); res } diff --git a/src/geometry/rotation_conversion.rs b/src/geometry/rotation_conversion.rs index 517010a0..c37b5cdd 100644 --- a/src/geometry/rotation_conversion.rs +++ b/src/geometry/rotation_conversion.rs @@ -211,8 +211,8 @@ where #[inline] fn is_in_subset(m: &OMatrix, U1>, DimNameSum, U1>>) -> bool { - let rot = m.fixed_slice::(0, 0); - let bottom = m.fixed_slice::<1, D>(D, 0); + let rot = m.fixed_view::(0, 0); + let bottom = m.fixed_view::<1, D>(D, 0); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && @@ -226,7 +226,7 @@ where fn from_superset_unchecked( m: &OMatrix, U1>, DimNameSum, U1>>, ) -> Self { - let r = m.fixed_slice::(0, 0); + let r = m.fixed_view::(0, 0); Self::from_matrix_unchecked(crate::convert_unchecked(r.into_owned())) } } diff --git a/src/geometry/scale_conversion.rs b/src/geometry/scale_conversion.rs index 2dc670a1..2d807e3a 100644 --- a/src/geometry/scale_conversion.rs +++ b/src/geometry/scale_conversion.rs @@ -102,7 +102,7 @@ where fn from_superset_unchecked( m: &OMatrix, U1>, DimNameSum, U1>>, ) -> Self { - let v = m.fixed_slice::(0, 0).diagonal(); + let v = m.fixed_view::(0, 0).diagonal(); Self { vector: crate::convert_unchecked(v), } diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index a827246e..763f1db9 100755 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -304,7 +304,7 @@ impl Similarity { { let mut res = self.isometry.to_homogeneous(); - for e in res.fixed_slice_mut::(0, 0).iter_mut() { + for e in res.fixed_view_mut::(0, 0).iter_mut() { *e *= self.scaling.clone() } diff --git a/src/geometry/similarity_conversion.rs b/src/geometry/similarity_conversion.rs index 6bc12814..e5d28906 100644 --- a/src/geometry/similarity_conversion.rs +++ b/src/geometry/similarity_conversion.rs @@ -106,7 +106,7 @@ where #[inline] fn is_in_subset(m: &OMatrix, U1>, DimNameSum, U1>>) -> bool { - let mut rot = m.fixed_slice::(0, 0).clone_owned(); + let mut rot = m.fixed_view::(0, 0).clone_owned(); if rot .fixed_columns_mut::<1>(0) .try_normalize_mut(T2::zero()) @@ -128,7 +128,7 @@ where rot.fixed_columns_mut::<1>(2).neg_mut(); } - let bottom = m.fixed_slice::<1, D>(D, 0); + let bottom = m.fixed_view::<1, D>(D, 0); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && // The normalized block part is a rotation. @@ -145,22 +145,22 @@ where m: &OMatrix, U1>, DimNameSum, U1>>, ) -> Self { let mut mm = m.clone_owned(); - let na = mm.fixed_slice_mut::(0, 0).normalize_mut(); - let nb = mm.fixed_slice_mut::(0, 1).normalize_mut(); - let nc = mm.fixed_slice_mut::(0, 2).normalize_mut(); + let na = mm.fixed_view_mut::(0, 0).normalize_mut(); + let nb = mm.fixed_view_mut::(0, 1).normalize_mut(); + let nc = mm.fixed_view_mut::(0, 2).normalize_mut(); let mut scale = (na + nb + nc) / crate::convert(3.0); // We take the mean, for robustness. // TODO: could we avoid the explicit computation of the determinant? // (its sign is needed to see if the scaling factor is negative). - if mm.fixed_slice::(0, 0).determinant() < T2::zero() { - mm.fixed_slice_mut::(0, 0).neg_mut(); - mm.fixed_slice_mut::(0, 1).neg_mut(); - mm.fixed_slice_mut::(0, 2).neg_mut(); + if mm.fixed_view::(0, 0).determinant() < T2::zero() { + mm.fixed_view_mut::(0, 0).neg_mut(); + mm.fixed_view_mut::(0, 1).neg_mut(); + mm.fixed_view_mut::(0, 2).neg_mut(); scale = -scale; } - let t = m.fixed_slice::(0, D).into_owned(); + let t = m.fixed_view::(0, D).into_owned(); let t = Translation { vector: crate::convert_unchecked(t), }; diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 8a500676..4c6284d0 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -120,10 +120,10 @@ md_impl_all!( [ref val] => self * &rhs; [val ref] => &self * rhs; [ref ref] => { - let transform = self.matrix().fixed_slice::(0, 0); + let transform = self.matrix().fixed_view::(0, 0); if C::has_normalizer() { - let normalizer = self.matrix().fixed_slice::<1, D>(D, 0); + let normalizer = self.matrix().fixed_view::<1, D>(D, 0); let n = normalizer.tr_dot(rhs); if !n.is_zero() { @@ -148,11 +148,11 @@ md_impl_all!( [ref val] => self * &rhs; [val ref] => &self * rhs; [ref ref] => { - let transform = self.matrix().fixed_slice::(0, 0); - let translation = self.matrix().fixed_slice::(0, D); + let transform = self.matrix().fixed_view::(0, 0); + let translation = self.matrix().fixed_view::(0, D); if C::has_normalizer() { - let normalizer = self.matrix().fixed_slice::<1, D>(D, 0); + let normalizer = self.matrix().fixed_view::<1, D>(D, 0); #[allow(clippy::suspicious_arithmetic_impl)] let n = normalizer.tr_dot(&rhs.coords) + unsafe { self.matrix().get_unchecked((D, D)).clone() }; diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index 7e10ac4c..482d45ed 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -150,7 +150,7 @@ impl Translation { DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { let mut res = OMatrix::, U1>, DimNameSum, U1>>::identity(); - res.fixed_slice_mut::(0, D).copy_from(&self.vector); + res.fixed_view_mut::(0, D).copy_from(&self.vector); res } diff --git a/src/geometry/translation_conversion.rs b/src/geometry/translation_conversion.rs index 70000efb..73646780 100644 --- a/src/geometry/translation_conversion.rs +++ b/src/geometry/translation_conversion.rs @@ -159,7 +159,7 @@ where #[inline] fn is_in_subset(m: &OMatrix, U1>, DimNameSum, U1>>) -> bool { - let id = m.generic_slice((0, 0), (DimNameSum::, U1>::name(), Const::)); + let id = m.generic_view((0, 0), (DimNameSum::, U1>::name(), Const::)); // Scalar types agree. m.iter().all(|e| SupersetOf::::is_in_subset(e)) && @@ -173,7 +173,7 @@ where fn from_superset_unchecked( m: &OMatrix, U1>, DimNameSum, U1>>, ) -> Self { - let t = m.fixed_slice::(0, D); + let t = m.fixed_view::(0, D); Self { vector: crate::convert_unchecked(t.into_owned()), } diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index c6b02975..56591ab1 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -202,7 +202,7 @@ where ); let start = self.axis_shift(); - res.slice_mut(start, (d.value() - 1, d.value() - 1)) + res.view_mut(start, (d.value() - 1, d.value() - 1)) .set_partial_diagonal( self.off_diagonal .iter() @@ -226,11 +226,11 @@ where let shift = self.axis_shift().0; for i in (0..dim - shift).rev() { - let axis = self.uv.slice_range(i + shift.., i); + let axis = self.uv.view_range(i + shift.., i); // TODO: sometimes, the axis might have a zero magnitude. let refl = Reflection::new(Unit::new_unchecked(axis), T::zero()); - let mut res_rows = res.slice_range_mut(i + shift.., i..); + let mut res_rows = res.view_range_mut(i + shift.., i..); let sign = if self.upper_diagonal { self.diagonal[i].clone().signum() @@ -260,13 +260,13 @@ where let shift = self.axis_shift().1; for i in (0..min_nrows_ncols.value() - shift).rev() { - let axis = self.uv.slice_range(i, i + shift..); + let axis = self.uv.view_range(i, i + shift..); let mut axis_packed = axis_packed.rows_range_mut(i + shift..); axis_packed.tr_copy_from(&axis); // TODO: sometimes, the axis might have a zero magnitude. let refl = Reflection::new(Unit::new_unchecked(axis_packed), T::zero()); - let mut res_rows = res.slice_range_mut(i.., i + shift..); + let mut res_rows = res.view_range_mut(i.., i + shift..); let sign = if self.upper_diagonal { self.off_diagonal[i].clone().signum() @@ -346,7 +346,7 @@ where // *b.vget_unchecked_mut(i) = coeff; // } // -// b.rows_range_mut(.. i).axpy(-coeff, &self.uv.slice_range(.. i, i), T::one()); +// b.rows_range_mut(.. i).axpy(-coeff, &self.uv.view_range(.. i, i), T::one()); // } // } // } diff --git a/src/linalg/cholesky.rs b/src/linalg/cholesky.rs index f61a4e63..4d530927 100644 --- a/src/linalg/cholesky.rs +++ b/src/linalg/cholesky.rs @@ -67,7 +67,7 @@ where *matrix.get_unchecked_mut((j, j)) = denom.clone(); } - let mut col = matrix.slice_range_mut(j + 1.., j); + let mut col = matrix.view_range_mut(j + 1.., j); col /= denom; } @@ -228,7 +228,7 @@ where *matrix.get_unchecked_mut((j, j)) = denom.clone(); } - let mut col = matrix.slice_range_mut(j + 1.., j); + let mut col = matrix.view_range_mut(j + 1.., j); col /= denom; continue; } @@ -283,17 +283,17 @@ where self.chol.shape_generic().0.add(Const::<1>), self.chol.shape_generic().1.add(Const::<1>), ); - chol.slice_range_mut(..j, ..j) - .copy_from(&self.chol.slice_range(..j, ..j)); - chol.slice_range_mut(..j, j + 1..) - .copy_from(&self.chol.slice_range(..j, j..)); - chol.slice_range_mut(j + 1.., ..j) - .copy_from(&self.chol.slice_range(j.., ..j)); - chol.slice_range_mut(j + 1.., j + 1..) - .copy_from(&self.chol.slice_range(j.., j..)); + chol.view_range_mut(..j, ..j) + .copy_from(&self.chol.view_range(..j, ..j)); + chol.view_range_mut(..j, j + 1..) + .copy_from(&self.chol.view_range(..j, j..)); + chol.view_range_mut(j + 1.., ..j) + .copy_from(&self.chol.view_range(j.., ..j)); + chol.view_range_mut(j + 1.., j + 1..) + .copy_from(&self.chol.view_range(j.., j..)); // update the jth row - let top_left_corner = self.chol.slice_range(..j, ..j); + let top_left_corner = self.chol.view_range(..j, ..j); let col_j = col[j].clone(); let (mut new_rowj_adjoint, mut new_colj) = col.rows_range_pair_mut(..j, j + 1..); @@ -302,14 +302,14 @@ where "Cholesky::insert_column : Unable to solve lower triangular system!" ); - new_rowj_adjoint.adjoint_to(&mut chol.slice_range_mut(j, ..j)); + new_rowj_adjoint.adjoint_to(&mut chol.view_range_mut(j, ..j)); // update the center element let center_element = T::sqrt(col_j - T::from_real(new_rowj_adjoint.norm_squared())); chol[(j, j)] = center_element.clone(); // update the jth column - let bottom_left_corner = self.chol.slice_range(j.., ..j); + let bottom_left_corner = self.chol.view_range(j.., ..j); // new_colj = (col_jplus - bottom_left_corner * new_rowj.adjoint()) / center_element; new_colj.gemm( -T::one() / center_element.clone(), @@ -317,10 +317,10 @@ where &new_rowj_adjoint, T::one() / center_element, ); - chol.slice_range_mut(j + 1.., j).copy_from(&new_colj); + chol.view_range_mut(j + 1.., j).copy_from(&new_colj); // update the bottom right corner - let mut bottom_right_corner = chol.slice_range_mut(j + 1.., j + 1..); + let mut bottom_right_corner = chol.view_range_mut(j + 1.., j + 1..); Self::xx_rank_one_update( &mut bottom_right_corner, &mut new_colj, @@ -348,17 +348,17 @@ where self.chol.shape_generic().0.sub(Const::<1>), self.chol.shape_generic().1.sub(Const::<1>), ); - chol.slice_range_mut(..j, ..j) - .copy_from(&self.chol.slice_range(..j, ..j)); - chol.slice_range_mut(..j, j..) - .copy_from(&self.chol.slice_range(..j, j + 1..)); - chol.slice_range_mut(j.., ..j) - .copy_from(&self.chol.slice_range(j + 1.., ..j)); - chol.slice_range_mut(j.., j..) - .copy_from(&self.chol.slice_range(j + 1.., j + 1..)); + chol.view_range_mut(..j, ..j) + .copy_from(&self.chol.view_range(..j, ..j)); + chol.view_range_mut(..j, j..) + .copy_from(&self.chol.view_range(..j, j + 1..)); + chol.view_range_mut(j.., ..j) + .copy_from(&self.chol.view_range(j + 1.., ..j)); + chol.view_range_mut(j.., j..) + .copy_from(&self.chol.view_range(j + 1.., j + 1..)); // updates the bottom right corner - let mut bottom_right_corner = chol.slice_range_mut(j.., j..); + let mut bottom_right_corner = chol.view_range_mut(j.., j..); let mut workspace = self.chol.column(j).clone_owned(); let mut old_colj = workspace.rows_range_mut(j + 1..); Self::xx_rank_one_update(&mut bottom_right_corner, &mut old_colj, T::RealField::one()); @@ -370,7 +370,7 @@ where /// performs a rank one update such that we end up with the decomposition of `M + sigma * (x * x.adjoint())`. /// /// This helper method is called by `rank_one_update` but also `insert_column` and `remove_column` - /// where it is used on a square slice of the decomposition + /// where it is used on a square view of the decomposition fn xx_rank_one_update( chol: &mut Matrix, x: &mut Vector, @@ -404,7 +404,7 @@ where beta += sigma_xj2 / diag2; // updates the terms of L let mut xjplus = x.rows_range_mut(j + 1..); - let mut col_j = chol.slice_range_mut(j + 1.., j); + let mut col_j = chol.view_range_mut(j + 1.., j); // temp_jplus -= (wj / T::from_real(diag)) * col_j; xjplus.axpy(-xj.clone() / T::from_real(diag.clone()), &col_j, T::one()); if gamma != crate::zero::() { diff --git a/src/linalg/col_piv_qr.rs b/src/linalg/col_piv_qr.rs index 822448e3..bd234b60 100644 --- a/src/linalg/col_piv_qr.rs +++ b/src/linalg/col_piv_qr.rs @@ -78,7 +78,7 @@ where let mut diag = Matrix::uninit(min_nrows_ncols, Const::<1>); for i in 0..min_nrows_ncols.value() { - let piv = matrix.slice_range(i.., i..).icamax_full(); + let piv = matrix.view_range(i.., i..).icamax_full(); let col_piv = piv.1 + i; matrix.swap_columns(i, col_piv); p.append_permutation(i, col_piv); @@ -144,11 +144,11 @@ where let dim = self.diag.len(); for i in (0..dim).rev() { - let axis = self.col_piv_qr.slice_range(i.., i); + let axis = self.col_piv_qr.view_range(i.., i); // TODO: sometimes, the axis might have a zero magnitude. let refl = Reflection::new(Unit::new_unchecked(axis), T::zero()); - let mut res_rows = res.slice_range_mut(i.., i..); + let mut res_rows = res.view_range_mut(i.., i..); refl.reflect_with_sign(&mut res_rows, self.diag[i].clone().signum()); } @@ -191,7 +191,7 @@ where let dim = self.diag.len(); for i in 0..dim { - let axis = self.col_piv_qr.slice_range(i.., i); + let axis = self.col_piv_qr.view_range(i.., i); let refl = Reflection::new(Unit::new_unchecked(axis), T::zero()); let mut rhs_rows = rhs.rows_range_mut(i..); @@ -281,7 +281,7 @@ where } b.rows_range_mut(..i) - .axpy(-coeff, &self.col_piv_qr.slice_range(..i, i), T::one()); + .axpy(-coeff, &self.col_piv_qr.view_range(..i, i), T::one()); } } diff --git a/src/linalg/full_piv_lu.rs b/src/linalg/full_piv_lu.rs index b11bf4d6..2037e285 100644 --- a/src/linalg/full_piv_lu.rs +++ b/src/linalg/full_piv_lu.rs @@ -64,7 +64,7 @@ where } for i in 0..min_nrows_ncols.value() { - let piv = matrix.slice_range(i.., i..).icamax_full(); + let piv = matrix.view_range(i.., i..).icamax_full(); let row_piv = piv.0 + i; let col_piv = piv.1 + i; let diag = matrix[(row_piv, col_piv)].clone(); diff --git a/src/linalg/hessenberg.rs b/src/linalg/hessenberg.rs index 2f85d462..0313a0bb 100644 --- a/src/linalg/hessenberg.rs +++ b/src/linalg/hessenberg.rs @@ -113,7 +113,7 @@ where let dim = self.hess.nrows(); self.hess.fill_lower_triangle(T::zero(), 2); self.hess - .slice_mut((1, 0), (dim - 1, dim - 1)) + .view_mut((1, 0), (dim - 1, dim - 1)) .set_partial_diagonal( self.subdiag .iter() @@ -132,7 +132,7 @@ where let dim = self.hess.nrows(); let mut res = self.hess.clone(); res.fill_lower_triangle(T::zero(), 2); - res.slice_mut((1, 0), (dim - 1, dim - 1)) + res.view_mut((1, 0), (dim - 1, dim - 1)) .set_partial_diagonal( self.subdiag .iter() diff --git a/src/linalg/householder.rs b/src/linalg/householder.rs index 688930a3..79d7c768 100644 --- a/src/linalg/householder.rs +++ b/src/linalg/householder.rs @@ -128,10 +128,10 @@ where let mut res = OMatrix::identity_generic(dim, dim); for i in (0..dim.value() - 1).rev() { - let axis = m.slice_range(i + 1.., i); + let axis = m.view_range(i + 1.., i); let refl = Reflection::new(Unit::new_unchecked(axis), T::zero()); - let mut res_rows = res.slice_range_mut(i + 1.., i..); + let mut res_rows = res.view_range_mut(i + 1.., i..); refl.reflect_with_sign(&mut res_rows, signs[i].clone().signum()); } diff --git a/src/linalg/lu.rs b/src/linalg/lu.rs index 01ae46f0..a5e87072 100644 --- a/src/linalg/lu.rs +++ b/src/linalg/lu.rs @@ -64,7 +64,7 @@ where out.fill_with_identity(); for i in 0..dim { - let piv = matrix.slice_range(i.., i).icamax() + i; + let piv = matrix.view_range(i.., i).icamax() + i; let diag = matrix[(piv, i)].clone(); if diag.is_zero() { @@ -100,7 +100,7 @@ where } for i in 0..min_nrows_ncols.value() { - let piv = matrix.slice_range(i.., i).icamax() + i; + let piv = matrix.view_range(i.., i).icamax() + i; let diag = matrix[(piv, i)].clone(); if diag.is_zero() { @@ -338,7 +338,7 @@ where T: Scalar + Field, S: StorageMut, { - let mut submat = matrix.slice_range_mut(i.., i..); + let mut submat = matrix.view_range_mut(i.., i..); let inv_diag = T::one() / diag; @@ -368,7 +368,7 @@ pub fn gauss_step_swap( S: StorageMut, { let piv = piv - i; - let mut submat = matrix.slice_range_mut(i.., i..); + let mut submat = matrix.view_range_mut(i.., i..); let inv_diag = T::one() / diag; diff --git a/src/linalg/qr.rs b/src/linalg/qr.rs index 1b06e34b..54921939 100644 --- a/src/linalg/qr.rs +++ b/src/linalg/qr.rs @@ -116,11 +116,11 @@ where let dim = self.diag.len(); for i in (0..dim).rev() { - let axis = self.qr.slice_range(i.., i); + let axis = self.qr.view_range(i.., i); // TODO: sometimes, the axis might have a zero magnitude. let refl = Reflection::new(Unit::new_unchecked(axis), T::zero()); - let mut res_rows = res.slice_range_mut(i.., i..); + let mut res_rows = res.view_range_mut(i.., i..); refl.reflect_with_sign(&mut res_rows, self.diag[i].clone().signum()); } @@ -161,7 +161,7 @@ where let dim = self.diag.len(); for i in 0..dim { - let axis = self.qr.slice_range(i.., i); + let axis = self.qr.view_range(i.., i); let refl = Reflection::new(Unit::new_unchecked(axis), T::zero()); let mut rhs_rows = rhs.rows_range_mut(i..); @@ -247,7 +247,7 @@ where } b.rows_range_mut(..i) - .axpy(-coeff, &self.qr.slice_range(..i, i), T::one()); + .axpy(-coeff, &self.qr.view_range(..i, i), T::one()); } } diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index c7753cee..3388e7cf 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -174,19 +174,19 @@ where { let krows = cmp::min(k + 4, end + 1); let mut work = work.rows_mut(0, krows); - refl.reflect(&mut t.generic_slice_mut( + refl.reflect(&mut t.generic_view_mut( (k, k), (Const::<3>, Dynamic::new(dim.value() - k)), )); refl.reflect_rows( - &mut t.generic_slice_mut((0, k), (Dynamic::new(krows), Const::<3>)), + &mut t.generic_view_mut((0, k), (Dynamic::new(krows), Const::<3>)), &mut work, ); } if let Some(ref mut q) = q { refl.reflect_rows( - &mut q.generic_slice_mut((0, k), (dim, Const::<3>)), + &mut q.generic_view_mut((0, k), (dim, Const::<3>)), work, ); } @@ -211,38 +211,38 @@ where { let mut work = work.rows_mut(0, end + 1); - refl.reflect(&mut t.generic_slice_mut( + refl.reflect(&mut t.generic_view_mut( (m, m), (Const::<2>, Dynamic::new(dim.value() - m)), )); refl.reflect_rows( - &mut t.generic_slice_mut((0, m), (Dynamic::new(end + 1), Const::<2>)), + &mut t.generic_view_mut((0, m), (Dynamic::new(end + 1), Const::<2>)), &mut work, ); } if let Some(ref mut q) = q { refl.reflect_rows( - &mut q.generic_slice_mut((0, m), (dim, Const::<2>)), + &mut q.generic_view_mut((0, m), (dim, Const::<2>)), work, ); } } } else { // Decouple the 2x2 block if it has real eigenvalues. - if let Some(rot) = compute_2x2_basis(&t.fixed_slice::<2, 2>(start, start)) { + if let Some(rot) = compute_2x2_basis(&t.fixed_view::<2, 2>(start, start)) { let inv_rot = rot.inverse(); - inv_rot.rotate(&mut t.generic_slice_mut( + inv_rot.rotate(&mut t.generic_view_mut( (start, start), (Const::<2>, Dynamic::new(dim.value() - start)), )); rot.rotate_rows( - &mut t.generic_slice_mut((0, start), (Dynamic::new(end + 1), Const::<2>)), + &mut t.generic_view_mut((0, start), (Dynamic::new(end + 1), Const::<2>)), ); t[(end, start)] = T::zero(); if let Some(ref mut q) = q { - rot.rotate_rows(&mut q.generic_slice_mut((0, start), (dim, Const::<2>))); + rot.rotate_rows(&mut q.generic_view_mut((0, start), (dim, Const::<2>))); } } @@ -427,9 +427,9 @@ where { let dim = m.shape_generic().0; let mut q = None; - match compute_2x2_basis(&m.fixed_slice::<2, 2>(0, 0)) { + match compute_2x2_basis(&m.fixed_view::<2, 2>(0, 0)) { Some(rot) => { - let mut m = m.fixed_slice_mut::<2, 2>(0, 0); + let mut m = m.fixed_view_mut::<2, 2>(0, 0); let inv_rot = rot.inverse(); inv_rot.rotate(&mut m); rot.rotate_rows(&mut m); @@ -530,7 +530,7 @@ where if self.nrows() == 2 { // TODO: can we avoid this slicing // (which is needed here just to transform D to U2)? - let me = self.fixed_slice::<2, 2>(0, 0); + let me = self.fixed_view::<2, 2>(0, 0); return match compute_2x2_eigvals(&me) { Some((a, b)) => { work[0] = a; diff --git a/src/linalg/solve.rs b/src/linalg/solve.rs index c355f2d0..237986a8 100644 --- a/src/linalg/solve.rs +++ b/src/linalg/solve.rs @@ -93,7 +93,7 @@ impl> SquareMatrix { } b.rows_range_mut(i + 1..) - .axpy(-coeff, &self.slice_range(i + 1.., i), T::one()); + .axpy(-coeff, &self.view_range(i + 1.., i), T::one()); } true @@ -125,7 +125,7 @@ impl> SquareMatrix { for i in 0..dim - 1 { let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone(); bcol.rows_range_mut(i + 1..) - .axpy(-coeff, &self.slice_range(i + 1.., i), T::one()); + .axpy(-coeff, &self.view_range(i + 1.., i), T::one()); } } @@ -175,7 +175,7 @@ impl> SquareMatrix { } b.rows_range_mut(..i) - .axpy(-coeff, &self.slice_range(..i, i), T::one()); + .axpy(-coeff, &self.view_range(..i, i), T::one()); } true @@ -387,7 +387,7 @@ impl> SquareMatrix { let dim = self.nrows(); for i in (0..dim).rev() { - let dot = dot(&self.slice_range(i + 1.., i), &b.slice_range(i + 1.., 0)); + let dot = dot(&self.view_range(i + 1.., i), &b.view_range(i + 1.., 0)); unsafe { let b_i = b.vget_unchecked_mut(i); @@ -422,7 +422,7 @@ impl> SquareMatrix { let dim = self.nrows(); for i in 0..dim { - let dot = dot(&self.slice_range(..i, i), &b.slice_range(..i, 0)); + let dot = dot(&self.view_range(..i, i), &b.view_range(..i, 0)); unsafe { let b_i = b.vget_unchecked_mut(i); @@ -514,7 +514,7 @@ impl> SquareMatrix { } b.rows_range_mut(i + 1..) - .axpy(-coeff.clone(), &self.slice_range(i + 1.., i), T::one()); + .axpy(-coeff.clone(), &self.view_range(i + 1.., i), T::one()); } } @@ -539,7 +539,7 @@ impl> SquareMatrix { for i in 0..dim - 1 { let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone(); bcol.rows_range_mut(i + 1..) - .axpy(-coeff, &self.slice_range(i + 1.., i), T::one()); + .axpy(-coeff, &self.view_range(i + 1.., i), T::one()); } } } @@ -575,7 +575,7 @@ impl> SquareMatrix { } b.rows_range_mut(..i) - .axpy(-coeff, &self.slice_range(..i, i), T::one()); + .axpy(-coeff, &self.view_range(..i, i), T::one()); } } @@ -744,7 +744,7 @@ impl> SquareMatrix { let dim = self.nrows(); for i in (0..dim).rev() { - let dot = dot(&self.slice_range(i + 1.., i), &b.slice_range(i + 1.., 0)); + let dot = dot(&self.view_range(i + 1.., i), &b.view_range(i + 1.., 0)); unsafe { let b_i = b.vget_unchecked_mut(i); @@ -768,7 +768,7 @@ impl> SquareMatrix { ShapeConstraint: SameNumberOfRows, { for i in 0..self.nrows() { - let dot = dot(&self.slice_range(..i, i), &b.slice_range(..i, 0)); + let dot = dot(&self.view_range(..i, i), &b.view_range(..i, 0)); unsafe { let b_i = b.vget_unchecked_mut(i);