Trait peroxide::traits::fp::ParallelFPVector
source · pub trait ParallelFPVector {
type Scalar;
// Required methods
fn par_fmap<F>(&self, f: F) -> Self
where F: Fn(Self::Scalar) -> Self::Scalar + Send + Sync;
fn par_reduce<F, T>(&self, init: T, f: F) -> Self::Scalar
where F: Fn(Self::Scalar, Self::Scalar) -> Self::Scalar + Send + Sync,
T: Into<Self::Scalar> + Send + Sync + Copy;
fn par_zip_with<F>(&self, f: F, other: &Self) -> Self
where F: Fn(Self::Scalar, Self::Scalar) -> Self::Scalar + Send + Sync;
fn par_filter<F>(&self, f: F) -> Self
where F: Fn(Self::Scalar) -> bool + Send + Sync;
}
Expand description
Functional Programming tools for Vector in Parallel (Uses Rayon crate)
Required Associated Types§
Required Methods§
fn par_fmap<F>(&self, f: F) -> Self
fn par_reduce<F, T>(&self, init: T, f: F) -> Self::Scalar
fn par_zip_with<F>(&self, f: F, other: &Self) -> Self
fn par_filter<F>(&self, f: F) -> Self
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl ParallelFPVector for Vec<f64>
impl ParallelFPVector for Vec<f64>
source§fn par_fmap<F>(&self, f: F) -> Vec<f64>
fn par_fmap<F>(&self, f: F) -> Vec<f64>
par_fmap for Vec<f64>
§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;
use peroxide::traits::fp::ParallelFPVector;
fn main() {
let a = c!(1,2,3,4,5);
assert_eq!(a.par_fmap(|x| x*2f64), seq!(2,10,2));
}
source§fn par_reduce<F, T>(&self, _init: T, f: F) -> f64
fn par_reduce<F, T>(&self, _init: T, f: F) -> f64
reduce for Vec<f64>
§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;
use peroxide::traits::fp::ParallelFPVector;
fn main() {
let a = seq!(1,100,1);
assert_eq!(a.par_reduce(0, |x,y| x + y), 5050f64);
}
source§fn par_filter<F>(&self, f: F) -> Vec<f64>
fn par_filter<F>(&self, f: F) -> Vec<f64>
Filter for Vec<f64>
§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;
use peroxide::traits::fp::ParallelFPVector;
fn main() {
let a = c!(1,2,3,4,5);
let b = a.par_filter(|x| x > 3.);
assert_eq!(b, c!(4,5));
}