This commit is contained in:
geo-ant 2022-11-27 16:51:45 +01:00 committed by Sébastien Crozet
parent 61abece7af
commit 50e25c57f7
2 changed files with 22 additions and 18 deletions

View File

@ -8,8 +8,8 @@ use crate::{
iter::{ColumnIter, ColumnIterMut},
Dim, Matrix, MatrixSlice, MatrixSliceMut, RawStorage, RawStorageMut, Scalar, U1,
};
use rayon::{iter::plumbing::bridge, prelude::*};
use rayon::iter::plumbing::Producer;
use rayon::{iter::plumbing::bridge, prelude::*};
/// A rayon parallel iterator over the colums of a matrix. It is created
/// using the [`par_column_iter`] method of [`Matrix`].
@ -228,7 +228,8 @@ struct ColumnProducer<'a,T,R:Dim,C:Dim,S:RawStorage<T,R,C>>(ColumnIter<'a,T,R,C,
#[cfg_attr(doc_cfg, doc(cfg(feature = "par-iter")))]
/// *only available if compiled with the feature `par-iter`*
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> Producer for ColumnProducer<'a, T, R, Cols, S>
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> Producer
for ColumnProducer<'a, T, R, Cols, S>
where
T: Send + Sync + Scalar,
S: Sync,
@ -260,7 +261,9 @@ S: Sync,
/// See `ColumnProducer`. A private wrapper newtype that keeps the Producer
/// implementation private
struct ColumnProducerMut<'a, T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>>(ColumnIterMut<'a,T,R,C,S>);
struct ColumnProducerMut<'a, T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>>(
ColumnIterMut<'a, T, R, C, S>,
);
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Producer
for ColumnProducerMut<'a, T, R, C, S>
@ -294,7 +297,6 @@ S: Send + Sync,
}
}
/// this implementation is safe because we are enforcing exclusive access
/// to the columns through the active range of the iterator
unsafe impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Send

View File

@ -1240,7 +1240,9 @@ fn parallel_column_iteration() {
// repeat this test using mutable iterators
let mut dmat = dmat;
dmat.par_column_iter_mut().enumerate().for_each(|(idx, col)| {
dmat.par_column_iter_mut()
.enumerate()
.for_each(|(idx, col)| {
assert_eq!(col, cloned.column(idx));
});