pub mod vietoris_rips;
pub trait Filtration {
type InputSpace;
type InputParameter;
type OutputSpace;
type OutputParameter;
fn build(
&self,
input: &Self::InputSpace,
input_param: Self::InputParameter,
output_param: &Self::OutputParameter,
) -> Self::OutputSpace;
fn build_serial(
&self,
input: &Self::InputSpace,
input_param: Vec<Self::InputParameter>,
output_param: &Self::OutputParameter,
) -> Vec<Self::OutputSpace> {
input_param.into_iter().map(|p| self.build(input, p, output_param)).collect()
}
}
#[cfg(feature = "parallel")] use rayon::prelude::*;
#[cfg(feature = "parallel")]
pub trait ParallelFiltration: Filtration
where
Self: Sync,
Self::InputSpace: Sync,
Self::InputParameter: Send,
Self::OutputSpace: Send,
Self::OutputParameter: Send + Sync, {
fn build_parallel(
&self,
input: &Self::InputSpace,
input_param: Vec<Self::InputParameter>,
output_param: &Self::OutputParameter,
) -> Vec<Self::OutputSpace> {
input_param.into_par_iter().map(|p| self.build(input, p, output_param)).collect()
}
}