pub struct KahanSum<T: Float> { /* private fields */ }
Implementations§
Source§impl<T: Float> KahanSum<T>
Represents an ongoing Kahan summation. New terms can be added
to the sum by simple addition.
impl<T: Float> KahanSum<T>
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());
Sourcepub fn new_with_value(initial: T) -> Self
pub fn new_with_value(initial: T) -> Self
Creates a new KahanSum
with starting sum set to initial
, but err initalized to 0
Trait Implementations§
Source§impl<T: Float> AddAssign<&KahanSum<T>> for KahanSum<T>
impl<T: Float> AddAssign<&KahanSum<T>> for KahanSum<T>
Source§fn add_assign(&mut self, rhs: &KahanSum<T>)
fn add_assign(&mut self, rhs: &KahanSum<T>)
Performs the
+=
operation. Read moreSource§impl<T: Float> AddAssign<T> for KahanSum<T>
impl<T: Float> AddAssign<T> for KahanSum<T>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+=
operation. Read moreSource§impl<T: Float> AddAssign for KahanSum<T>
impl<T: Float> AddAssign for KahanSum<T>
Source§fn add_assign(&mut self, rhs: KahanSum<T>)
fn add_assign(&mut self, rhs: KahanSum<T>)
Performs the
+=
operation. Read moreAuto Trait Implementations§
impl<T> Freeze for KahanSum<T>where
T: Freeze,
impl<T> RefUnwindSafe for KahanSum<T>where
T: RefUnwindSafe,
impl<T> Send for KahanSum<T>where
T: Send,
impl<T> Sync for KahanSum<T>where
T: Sync,
impl<T> Unpin for KahanSum<T>where
T: Unpin,
impl<T> UnwindSafe for KahanSum<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more