[−][src]Struct kahan::KahanSum
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(&self) -> 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.
fn add(self, rhs: T) -> Self::Output
[src]
impl<'_, T: Float> Add<&'_ KahanSum<T>> for KahanSum<T>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: &KahanSum<T>) -> Self::Output
[src]
impl<T: Float> Add<KahanSum<T>> for KahanSum<T>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: KahanSum<T>) -> Self::Output
[src]
impl<T: Float> AddAssign<T> for KahanSum<T>
[src]
fn add_assign(&mut self, rhs: T)
[src]
impl<'_, T: Float> AddAssign<&'_ KahanSum<T>> for KahanSum<T>
[src]
fn add_assign(&mut self, rhs: &KahanSum<T>)
[src]
impl<T: Float> AddAssign<KahanSum<T>> for KahanSum<T>
[src]
fn add_assign(&mut self, rhs: KahanSum<T>)
[src]
Auto Trait Implementations
impl<T> Sync for KahanSum<T> where
T: Sync,
T: Sync,
impl<T> Unpin for KahanSum<T> where
T: Unpin,
T: Unpin,
impl<T> Send for KahanSum<T> where
T: Send,
T: Send,
impl<T> UnwindSafe for KahanSum<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for KahanSum<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,