#![no_std]
pub trait Model<Data> {
fn residual(&self, data: &Data) -> f64;
}
pub trait Estimator<Data> {
type Model: Model<Data>;
type ModelIter: IntoIterator<Item = Self::Model>;
const MIN_SAMPLES: usize;
fn estimate<I>(&self, data: I) -> Self::ModelIter
where
I: Iterator<Item = Data> + Clone;
}
pub trait Consensus<E, Data>
where
E: Estimator<Data>,
{
type Inliers: IntoIterator<Item = usize>;
fn model<I>(&mut self, estimator: &E, data: I) -> Option<E::Model>
where
I: Iterator<Item = Data> + Clone;
fn model_inliers<I>(&mut self, estimator: &E, data: I) -> Option<(E::Model, Self::Inliers)>
where
I: Iterator<Item = Data> + Clone;
}
pub trait MultiConsensus<E, Data>
where
E: Estimator<Data>,
{
type Inliers: IntoIterator<Item = usize>;
type Models: IntoIterator<Item = (E::Model, Self::Inliers)>;
fn models<I>(&mut self, estimator: &E, data: I) -> Self::Models
where
I: Iterator<Item = Data> + Clone;
}