Struct kahan::KahanSum
[−]
[src]
pub struct KahanSum<T: Float> { /* fields omitted */ }
Methods
impl<T: Float> KahanSum<T>
[src]
Represents an ongoing Kahan summation. New terms can be added to the sum by simple addition.
Examples
let mut kahan_sum = KahanSum::new(); kahan_sum += 10000.0f32; kahan_sum += 3.14159f32; assert_eq!(10003.142f32, kahan_sum.sum()); assert_eq!(0.000011444092f32, kahan_sum.err());
fn new() -> Self
[src]
Creates a new KahanSum
with sum and err initialized to 0
fn new_with_value(initial: T) -> Self
[src]
Creates a new KahanSum
with starting sum set to initial
, but err initalized to 0
fn sum(&self) -> T
[src]
Returns the current running sum
fn err(&self) -> T
[src]
Returns the current error value
Trait Implementations
impl<T: Debug + Float> Debug for KahanSum<T>
[src]
impl<T: Clone + Float> Clone for KahanSum<T>
[src]
fn clone(&self) -> KahanSum<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Float> Default for KahanSum<T>
[src]
impl<T: Float> AddAssign<T> for KahanSum<T>
[src]
fn add_assign(&mut self, rhs: T)
[src]
Performs the +=
operation.