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§

source

fn par_fmap<F>(&self, f: F) -> Self
where F: Fn(Self::Scalar) -> Self::Scalar + Send + Sync,

source

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,

source

fn par_zip_with<F>(&self, f: F, other: &Self) -> Self
where F: Fn(Self::Scalar, Self::Scalar) -> Self::Scalar + Send + Sync,

source

fn par_filter<F>(&self, f: F) -> Self
where F: Fn(Self::Scalar) -> bool + Send + Sync,

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ParallelFPVector for Vec<f64>

source§

fn par_fmap<F>(&self, f: F) -> Vec<f64>
where F: Fn(f64) -> f64 + Sync + Send,

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
where F: Fn(f64, f64) -> f64 + Send + Sync, T: Into<f64> + Send + Sync + Copy,

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>
where F: Fn(f64) -> bool + Send + Sync,

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));
}
source§

type Scalar = f64

source§

fn par_zip_with<F>(&self, f: F, other: &Vec<f64>) -> Vec<f64>
where F: Fn(f64, f64) -> f64 + Send + Sync,

Implementors§