[go: up one dir, main page]

Trait accurate::DotAccumulator [] [src]

pub trait DotAccumulator<F>: Add<(F, F), Output=Self> + From<F> + Default {
    fn dot(&self) -> F;

    fn absorb<I>(self, it: I) -> Self where I: IntoIterator<Item=(F, F)> { ... }
}

Accumulates terms of a dot product

Required Methods

fn dot(&self) -> F

The dot product of all terms accumulated so far

Provided Methods

fn absorb<I>(self, it: I) -> Self where I: IntoIterator<Item=(F, F)>

Absorb the items of an iterator into the accumulator

Examples

use accurate::*;

let x = vec![1.0, 2.0, 3.0];
let y = x.clone();

let d = Dot2::default().absorb(x.into_iter().zip(y.into_iter()));
assert_eq!(14.0f64, d.dot())

Implementors