Reorganize matrix slice macros.

This commit is contained in:
Crozet Sébastien 2020-11-13 18:34:33 +01:00
parent 45f2fc4f92
commit 4c2192d9e0
1 changed files with 329 additions and 320 deletions

View File

@ -274,11 +274,6 @@ macro_rules! matrix_slice_impl(
$generic_slice_with_steps: ident,
$rows_range_pair: ident,
$columns_range_pair: ident) => {
/// A matrix slice.
pub type $MatrixSlice<'a, N, R, C, RStride, CStride>
= Matrix<N, R, C, $SliceStorage<'a, N, R, C, RStride, CStride>>;
impl<N: Scalar, R: Dim, C: Dim, S: $Storage<N, R, C>> Matrix<N, R, C, S> {
/*
*
* Row slicing.
@ -631,10 +626,18 @@ macro_rules! matrix_slice_impl(
}
}
}
}
);
matrix_slice_impl!(
/// A matrix slice.
pub type MatrixSlice<'a, N, R, C, RStride, CStride> =
Matrix<N, R, C, SliceStorage<'a, N, R, C, RStride, CStride>>;
/// A mutable matrix slice.
pub type MatrixSliceMut<'a, N, R, C, RStride, CStride> =
Matrix<N, R, C, SliceStorageMut<'a, N, R, C, RStride, CStride>>;
/// # Slicing based on index and length
impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
matrix_slice_impl!(
self: &Self, MatrixSlice, SliceStorage, Storage.get_address_unchecked(), &self.data;
row,
row_part,
@ -660,8 +663,11 @@ matrix_slice_impl!(
generic_slice_with_steps,
rows_range_pair,
columns_range_pair);
}
matrix_slice_impl!(
/// # Mutable slicing based on index and length
impl<N: Scalar, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S> {
matrix_slice_impl!(
self: &mut Self, MatrixSliceMut, SliceStorageMut, StorageMut.get_address_unchecked_mut(), &mut self.data;
row_mut,
row_part_mut,
@ -687,6 +693,7 @@ matrix_slice_impl!(
generic_slice_with_steps_mut,
rows_range_pair_mut,
columns_range_pair_mut);
}
/// A range with a size that may be known at compile-time.
///
@ -803,6 +810,7 @@ impl<D: Dim> SliceRange<D> for RangeFull {
}
}
/// # Slicing based on ranges
impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// Slices a sub-matrix containing the rows indexed by the range `rows` and the columns indexed
/// by the range `cols`.
@ -842,6 +850,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
}
}
/// # Mutable slicing based on ranges
impl<N: Scalar, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S> {
/// Slices a mutable sub-matrix containing the rows indexed by the range `rows` and the columns
/// indexed by the range `cols`.