forked from M-Labs/nalgebra
Reorganize matrix slice macros.
This commit is contained in:
parent
45f2fc4f92
commit
4c2192d9e0
@ -274,11 +274,6 @@ macro_rules! matrix_slice_impl(
|
|||||||
$generic_slice_with_steps: ident,
|
$generic_slice_with_steps: ident,
|
||||||
$rows_range_pair: ident,
|
$rows_range_pair: ident,
|
||||||
$columns_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.
|
* Row slicing.
|
||||||
@ -631,9 +626,17 @@ macro_rules! 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!(
|
matrix_slice_impl!(
|
||||||
self: &Self, MatrixSlice, SliceStorage, Storage.get_address_unchecked(), &self.data;
|
self: &Self, MatrixSlice, SliceStorage, Storage.get_address_unchecked(), &self.data;
|
||||||
row,
|
row,
|
||||||
@ -660,7 +663,10 @@ matrix_slice_impl!(
|
|||||||
generic_slice_with_steps,
|
generic_slice_with_steps,
|
||||||
rows_range_pair,
|
rows_range_pair,
|
||||||
columns_range_pair);
|
columns_range_pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # 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!(
|
matrix_slice_impl!(
|
||||||
self: &mut Self, MatrixSliceMut, SliceStorageMut, StorageMut.get_address_unchecked_mut(), &mut self.data;
|
self: &mut Self, MatrixSliceMut, SliceStorageMut, StorageMut.get_address_unchecked_mut(), &mut self.data;
|
||||||
row_mut,
|
row_mut,
|
||||||
@ -687,6 +693,7 @@ matrix_slice_impl!(
|
|||||||
generic_slice_with_steps_mut,
|
generic_slice_with_steps_mut,
|
||||||
rows_range_pair_mut,
|
rows_range_pair_mut,
|
||||||
columns_range_pair_mut);
|
columns_range_pair_mut);
|
||||||
|
}
|
||||||
|
|
||||||
/// A range with a size that may be known at compile-time.
|
/// 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> {
|
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
|
/// Slices a sub-matrix containing the rows indexed by the range `rows` and the columns indexed
|
||||||
/// by the range `cols`.
|
/// 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> {
|
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
|
/// Slices a mutable sub-matrix containing the rows indexed by the range `rows` and the columns
|
||||||
/// indexed by the range `cols`.
|
/// indexed by the range `cols`.
|
||||||
|
Loading…
Reference in New Issue
Block a user