[][src]Struct kahan::KahanSum

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());

pub fn new() -> Self[src]

Creates a new KahanSum with sum and err initialized to 0

pub fn new_with_value(initial: T) -> Self[src]

Creates a new KahanSum with starting sum set to initial, but err initalized to 0

pub fn sum(&self) -> T[src]

Returns the current running sum

pub fn err(&self) -> T[src]

Returns the current error value

Trait Implementations

impl<T: Float> Default for KahanSum<T>[src]

impl<T: Clone + Float> Clone for KahanSum<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: Debug + Float> Debug for KahanSum<T>[src]

impl<T: Float> Add<T> for KahanSum<T>[src]

type Output = Self

The resulting type after applying the + operator.

impl<'_, T: Float> Add<&'_ KahanSum<T>> for KahanSum<T>[src]

type Output = Self

The resulting type after applying the + operator.

impl<T: Float> Add<KahanSum<T>> for KahanSum<T>[src]

type Output = Self

The resulting type after applying the + operator.

impl<T: Float> AddAssign<T> for KahanSum<T>[src]

impl<'_, T: Float> AddAssign<&'_ KahanSum<T>> for KahanSum<T>[src]

impl<T: Float> AddAssign<KahanSum<T>> for KahanSum<T>[src]

Auto Trait Implementations

impl<T> Sync for KahanSum<T> where
    T: Sync

impl<T> Unpin for KahanSum<T> where
    T: Unpin

impl<T> Send for KahanSum<T> where
    T: Send

impl<T> UnwindSafe for KahanSum<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for KahanSum<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]