use crate::traits::{EvalF32, EvalF64, Map01F32, Map01F64, Measure};
pub struct NormalizedEval64<M, G> {
measure: M,
map: G,
}
impl<M, G> NormalizedEval64<M, G> {
pub fn new(measure: M, map: G) -> Self {
Self { measure, map }
}
}
impl<Ctx, M, G> EvalF64<Ctx> for NormalizedEval64<M, G>
where
Ctx: ?Sized,
M: Measure<Ctx>,
G: Map01F64<Input = M::Output>,
{
#[inline]
fn eval(&self, ctx: &Ctx) -> f64 {
*self.map.map(self.measure.measure(ctx))
}
}
pub struct NormalizedEval32<M, G> {
measure: M,
map: G,
}
impl<M, G> NormalizedEval32<M, G> {
pub fn new(measure: M, map: G) -> Self {
Self { measure, map }
}
}
impl<Ctx, M, G> EvalF32<Ctx> for NormalizedEval32<M, G>
where
Ctx: ?Sized,
M: Measure<Ctx>,
G: Map01F32<Input = M::Output>,
{
#[inline]
fn eval(&self, ctx: &Ctx) -> f32 {
*self.map.map(self.measure.measure(ctx))
}
}