add documentation
This commit is contained in:
parent
7ac536be07
commit
daade1cf5e
@ -311,15 +311,6 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> ColumnIter<'a, T, R, C,
|
||||
range: 0..mat.ncols(),
|
||||
}
|
||||
}
|
||||
/// a new column iterator covering column indices [begin,end)
|
||||
/// where begin is included in the range but index end is not
|
||||
/// begin must lie in [0,ncols] and end must lie in [0,ncols].
|
||||
pub(crate) fn with_range(mat: &'a Matrix<T, R, C, S>, range: Range<usize>) -> Self {
|
||||
debug_assert!(range.end <= mat.ncols());
|
||||
debug_assert!(range.start < mat.ncols());
|
||||
debug_assert!(range.start <= range.end);
|
||||
Self { mat, range }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> Iterator for ColumnIter<'a, T, R, C, S> {
|
||||
@ -384,7 +375,7 @@ where
|
||||
|
||||
fn split_at(self, index: usize) -> (Self, Self) {
|
||||
// the index is relative to the size of this current iterator
|
||||
// it will always start at zero
|
||||
// it will always start at zero so it serves as an offset
|
||||
let left = Self {
|
||||
mat: self.mat,
|
||||
range: self.range.start..(self.range.start + index),
|
||||
@ -465,7 +456,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> DoubleEndedI
|
||||
debug_assert!(self.range.start <= self.range.end);
|
||||
if !self.range.is_empty() {
|
||||
self.range.end -= 1;
|
||||
debug_assert!(self.range.end < unsafe { (*self.mat).ncols() });
|
||||
debug_assert!(self.range.end < self.mat.ncols());
|
||||
debug_assert!(self.range.end >= self.range.start);
|
||||
let pmat: *mut _ = self.mat;
|
||||
Some(unsafe { (*pmat).column_mut(self.range.end) })
|
||||
@ -490,7 +481,7 @@ where
|
||||
|
||||
fn split_at(self, index: usize) -> (Self, Self) {
|
||||
// the index is relative to the size of this current iterator
|
||||
// it will always start at zero
|
||||
// it will always start at zero so it serves as an offset
|
||||
let pmat: *mut _ = self.mat;
|
||||
|
||||
let left = Self {
|
||||
|
@ -1,26 +1,23 @@
|
||||
//! this module implements parallelators to make matrices work with
|
||||
//! the rayon crate seamlessly
|
||||
|
||||
use core::{
|
||||
fmt::Debug,
|
||||
};
|
||||
|
||||
use core::fmt::Debug;
|
||||
use rayon::{
|
||||
iter::plumbing::{bridge},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
iter::{ColumnIter, ColumnIterMut}, DMatrix, Dim, Matrix, MatrixSlice, MatrixSliceMut,
|
||||
iter::{ColumnIter, ColumnIterMut}, Dim, Matrix, MatrixSlice, MatrixSliceMut,
|
||||
RawStorage, RawStorageMut, U1,
|
||||
};
|
||||
|
||||
/// a rayon parallel iterator over the columns of a matrix
|
||||
/// A rayon parallel iterator over the colums of a matrix
|
||||
pub struct ParColumnIter<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> {
|
||||
mat: &'a Matrix<T, R, Cols, S>,
|
||||
}
|
||||
|
||||
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> ParColumnIter<'a, T, R, Cols, S> {
|
||||
/// create a new parallel iterator for the given matrix
|
||||
fn new(matrix: &'a Matrix<T, R, Cols, S>) -> Self {
|
||||
Self { mat: matrix }
|
||||
}
|
||||
@ -74,21 +71,21 @@ where
|
||||
T: Send + Sync + Clone + Debug + PartialEq + 'static,
|
||||
S: Sync,
|
||||
{
|
||||
/// TODO
|
||||
/// Iterate through the columns of the matrix in parallel using rayon.
|
||||
pub fn par_column_iter(&self) -> ParColumnIter<'_, T, R, Cols, S> {
|
||||
ParColumnIter::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO
|
||||
/// A rayon parallel iterator through the mutable columns of a matrix
|
||||
pub struct ParColumnIterMut<'a,T,R:Dim ,Cols:Dim, S:RawStorage<T,R,Cols>+RawStorageMut<T,R,Cols>> {
|
||||
mat : &'a mut Matrix<T,R,Cols,S>,
|
||||
}
|
||||
|
||||
impl<'a,T,R,Cols,S> ParColumnIterMut<'a,T,R,Cols,S>
|
||||
where R: Dim, Cols : Dim, S:RawStorage<T,R,Cols> + RawStorageMut<T,R,Cols> {
|
||||
/// TODO
|
||||
pub fn new(mat : &'a mut Matrix<T,R,Cols,S>) -> Self {
|
||||
/// create a new parallel iterator for the given matrix
|
||||
fn new(mat : &'a mut Matrix<T,R,Cols,S>) -> Self {
|
||||
Self {
|
||||
mat,
|
||||
}
|
||||
@ -135,7 +132,7 @@ where
|
||||
T: Send + Sync + Clone + Debug + PartialEq + 'static,
|
||||
S: Sync,
|
||||
{
|
||||
/// TODO
|
||||
/// Mutably iterate through the columns of this matrix in parallel using rayon
|
||||
pub fn par_column_iter_mut(&mut self) -> ParColumnIterMut<'_, T, R, Cols, S> {
|
||||
ParColumnIterMut::new(self)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user