peroxide/traits/
mutable.rs

1use crate::structure::matrix::Shape;
2
3pub trait MutFP {
4    type Scalar;
5    fn mut_map<F>(&mut self, f: F)
6    where
7        F: Fn(Self::Scalar) -> Self::Scalar;
8    fn mut_zip_with<F>(&mut self, f: F, other: &Self)
9    where
10        F: Fn(Self::Scalar, Self::Scalar) -> Self::Scalar;
11}
12
13pub trait MutMatrix {
14    type Scalar;
15
16    unsafe fn col_mut(&mut self, idx: usize) -> Vec<*mut Self::Scalar>;
17    unsafe fn row_mut(&mut self, idx: usize) -> Vec<*mut Self::Scalar>;
18    unsafe fn swap(&mut self, idx1: usize, idx2: usize, shape: Shape);
19    unsafe fn swap_with_perm(&mut self, p: &Vec<(usize, usize)>, shape: Shape);
20}
21
22// Mutable trait for Vector in Parallel (Uses Rayon crate)
23pub trait ParallelMutFP {
24    type Scalar;
25    fn par_mut_map<F>(&mut self, f: F)
26    where
27        F: Fn(Self::Scalar) -> Self::Scalar + Send + Sync;
28    fn par_mut_zip_with<F>(&mut self, f: F, other: &Self)
29    where
30        F: Fn(Self::Scalar, Self::Scalar) -> Self::Scalar + Send + Sync;
31}