From 7d5097b0b2b98e0a17867ed28086dcb3c927cb6a Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Mon, 14 Nov 2022 09:33:08 +0100 Subject: [PATCH] Remove use of deprecated *Slice aliases in nalgebra --- src/base/blas.rs | 8 ++++---- src/base/conversion.rs | 24 ++++++++++++------------ src/base/ops.rs | 6 +++--- src/base/statistics.rs | 8 ++++---- src/linalg/solve.rs | 18 +++++++++--------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/base/blas.rs b/src/base/blas.rs index e65304b5..5f51cea9 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -11,7 +11,7 @@ use crate::base::dimension::{Const, Dim, Dynamic, U1, U2, U3, U4}; use crate::base::storage::{Storage, StorageMut}; use crate::base::uninit::Init; use crate::base::{ - DVectorSlice, DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector, VectorSlice, + DVectorView, DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector, VectorView, }; /// # Dot/scalar product @@ -363,8 +363,8 @@ where x: &Vector, beta: T, dot: impl Fn( - &DVectorSlice<'_, T, SB::RStride, SB::CStride>, - &DVectorSlice<'_, T, SC::RStride, SC::CStride>, + &DVectorView<'_, T, SB::RStride, SB::CStride>, + &DVectorView<'_, T, SC::RStride, SC::CStride>, ) -> T, ) where T: One, @@ -506,7 +506,7 @@ where a: &Matrix, x: &Vector, beta: T, - dot: impl Fn(&VectorSlice<'_, T, R2, SB::RStride, SB::CStride>, &Vector) -> T, + dot: impl Fn(&VectorView<'_, T, R2, SB::RStride, SB::CStride>, &Vector) -> T, ) where T: One, SB: Storage, diff --git a/src/base/conversion.rs b/src/base/conversion.rs index 9b6df2c2..4c83796e 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -16,14 +16,14 @@ use crate::base::dimension::{ use crate::base::iter::{MatrixIter, MatrixIterMut}; use crate::base::storage::{IsContiguous, RawStorage, RawStorageMut}; use crate::base::{ - ArrayStorage, DVectorSlice, DVectorSliceMut, DefaultAllocator, Matrix, MatrixView, + ArrayStorage, DVectorView, DVectorViewMut, DefaultAllocator, Matrix, MatrixView, MatrixViewMut, OMatrix, Scalar, }; #[cfg(any(feature = "std", feature = "alloc"))] use crate::base::{DVector, RowDVector, VecStorage}; use crate::base::{ViewStorage, ViewStorageMut}; use crate::constraint::DimEq; -use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector, VectorSlice, VectorSliceMut}; +use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector, VectorView, VectorViewMut}; use std::mem::MaybeUninit; // TODO: too bad this won't work for slice conversions. @@ -126,19 +126,19 @@ impl From> for [T; D] { } impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize> - From, RStride, CStride>> for [T; D] + From, RStride, CStride>> for [T; D] { #[inline] - fn from(vec: VectorSlice<'a, T, Const, RStride, CStride>) -> Self { + fn from(vec: VectorView<'a, T, Const, RStride, CStride>) -> Self { vec.into_owned().into() } } impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize> - From, RStride, CStride>> for [T; D] + From, RStride, CStride>> for [T; D] { #[inline] - fn from(vec: VectorSliceMut<'a, T, Const, RStride, CStride>) -> Self { + fn from(vec: VectorViewMut<'a, T, Const, RStride, CStride>) -> Self { vec.into_owned().into() } } @@ -515,28 +515,28 @@ impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: RawStorageMut + IsContigu } } -impl<'a, T: Scalar + Copy> From<&'a [T]> for DVectorSlice<'a, T> { +impl<'a, T: Scalar + Copy> From<&'a [T]> for DVectorView<'a, T> { #[inline] fn from(slice: &'a [T]) -> Self { Self::from_slice(slice, slice.len()) } } -impl<'a, T: Scalar> From> for &'a [T] { - fn from(vec: DVectorSlice<'a, T>) -> &'a [T] { +impl<'a, T: Scalar> From> for &'a [T] { + fn from(vec: DVectorView<'a, T>) -> &'a [T] { vec.data.into_slice() } } -impl<'a, T: Scalar + Copy> From<&'a mut [T]> for DVectorSliceMut<'a, T> { +impl<'a, T: Scalar + Copy> From<&'a mut [T]> for DVectorViewMut<'a, T> { #[inline] fn from(slice: &'a mut [T]) -> Self { Self::from_slice(slice, slice.len()) } } -impl<'a, T: Scalar> From> for &'a mut [T] { - fn from(vec: DVectorSliceMut<'a, T>) -> &'a mut [T] { +impl<'a, T: Scalar> From> for &'a mut [T] { + fn from(vec: DVectorViewMut<'a, T>) -> &'a mut [T] { vec.data.into_slice_mut() } } diff --git a/src/base/ops.rs b/src/base/ops.rs index 6b6d0c45..60ed5e26 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -14,7 +14,7 @@ use crate::base::constraint::{ use crate::base::dimension::{Dim, DimMul, DimName, DimProd, Dynamic}; use crate::base::storage::{Storage, StorageMut}; use crate::base::uninit::Uninit; -use crate::base::{DefaultAllocator, Matrix, MatrixSum, OMatrix, Scalar, VectorSlice}; +use crate::base::{DefaultAllocator, Matrix, MatrixSum, OMatrix, Scalar, VectorView}; use crate::storage::IsContiguous; use crate::uninit::{Init, InitStatus}; use crate::{RawStorage, RawStorageMut, SimdComplexField}; @@ -703,8 +703,8 @@ where rhs: &Matrix, out: &mut Matrix, dot: impl Fn( - &VectorSlice<'_, T, R1, SA::RStride, SA::CStride>, - &VectorSlice<'_, T, R2, SB::RStride, SB::CStride>, + &VectorView<'_, T, R1, SA::RStride, SA::CStride>, + &VectorView<'_, T, R2, SB::RStride, SB::CStride>, ) -> T, ) where Status: InitStatus, diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 320cd12f..9f0e0ee6 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -1,6 +1,6 @@ use crate::allocator::Allocator; use crate::storage::RawStorage; -use crate::{Const, DefaultAllocator, Dim, Matrix, OVector, RowOVector, Scalar, VectorSlice, U1}; +use crate::{Const, DefaultAllocator, Dim, Matrix, OVector, RowOVector, Scalar, VectorView, U1}; use num::{One, Zero}; use simba::scalar::{ClosedAdd, ClosedMul, Field, SupersetOf}; use std::mem::MaybeUninit; @@ -13,7 +13,7 @@ impl> Matrix { #[must_use] pub fn compress_rows( &self, - f: impl Fn(VectorSlice<'_, T, R, S::RStride, S::CStride>) -> T, + f: impl Fn(VectorView<'_, T, R, S::RStride, S::CStride>) -> T, ) -> RowOVector where DefaultAllocator: Allocator, @@ -41,7 +41,7 @@ impl> Matrix { #[must_use] pub fn compress_rows_tr( &self, - f: impl Fn(VectorSlice<'_, T, R, S::RStride, S::CStride>) -> T, + f: impl Fn(VectorView<'_, T, R, S::RStride, S::CStride>) -> T, ) -> OVector where DefaultAllocator: Allocator, @@ -67,7 +67,7 @@ impl> Matrix { pub fn compress_columns( &self, init: OVector, - f: impl Fn(&mut OVector, VectorSlice<'_, T, R, S::RStride, S::CStride>), + f: impl Fn(&mut OVector, VectorView<'_, T, R, S::RStride, S::CStride>), ) -> OVector where DefaultAllocator: Allocator, diff --git a/src/linalg/solve.rs b/src/linalg/solve.rs index 7409e7fb..c355f2d0 100644 --- a/src/linalg/solve.rs +++ b/src/linalg/solve.rs @@ -5,7 +5,7 @@ use crate::base::allocator::Allocator; use crate::base::constraint::{SameNumberOfRows, ShapeConstraint}; use crate::base::dimension::{Dim, U1}; use crate::base::storage::{Storage, StorageMut}; -use crate::base::{DVectorSlice, DefaultAllocator, Matrix, OMatrix, SquareMatrix, Vector}; +use crate::base::{DVectorView, DefaultAllocator, Matrix, OMatrix, SquareMatrix, Vector}; impl> SquareMatrix { /// Computes the solution of the linear system `self . x = b` where `x` is the unknown and only @@ -376,8 +376,8 @@ impl> SquareMatrix { b: &mut Vector, conjugate: impl Fn(T) -> T, dot: impl Fn( - &DVectorSlice<'_, T, S::RStride, S::CStride>, - &DVectorSlice<'_, T, S2::RStride, S2::CStride>, + &DVectorView<'_, T, S::RStride, S::CStride>, + &DVectorView<'_, T, S2::RStride, S2::CStride>, ) -> T, ) -> bool where @@ -411,8 +411,8 @@ impl> SquareMatrix { b: &mut Vector, conjugate: impl Fn(T) -> T, dot: impl Fn( - &DVectorSlice<'_, T, S::RStride, S::CStride>, - &DVectorSlice<'_, T, S2::RStride, S2::CStride>, + &DVectorView<'_, T, S::RStride, S::CStride>, + &DVectorView<'_, T, S2::RStride, S2::CStride>, ) -> T, ) -> bool where @@ -734,8 +734,8 @@ impl> SquareMatrix { b: &mut Vector, conjugate: impl Fn(T) -> T, dot: impl Fn( - &DVectorSlice<'_, T, S::RStride, S::CStride>, - &DVectorSlice<'_, T, S2::RStride, S2::CStride>, + &DVectorView<'_, T, S::RStride, S::CStride>, + &DVectorView<'_, T, S2::RStride, S2::CStride>, ) -> T, ) where S2: StorageMut, @@ -760,8 +760,8 @@ impl> SquareMatrix { b: &mut Vector, conjugate: impl Fn(T) -> T, dot: impl Fn( - &DVectorSlice<'_, T, S::RStride, S::CStride>, - &DVectorSlice<'_, T, S2::RStride, S2::CStride>, + &DVectorView<'_, T, S::RStride, S::CStride>, + &DVectorView<'_, T, S2::RStride, S2::CStride>, ) -> T, ) where S2: StorageMut,