Skip to main content

ScalarWithErrorBound

Struct ScalarWithErrorBound 

Source
#[non_exhaustive]
pub struct ScalarWithErrorBound { /* private fields */ }
Expand description

A scalar estimate paired with a certified absolute error bound.

Values of this type are produced by Vector::dot_with_errbound and Vector::dot_difference_with_errbound. The exact-real value of the corresponding expression over the stored binary64 inputs lies between lower_bound and upper_bound, and differs from estimate by at most absolute_error_bound.

The bound certifies floating-point roundoff in one specified arithmetic tree. It is not a caller-selected numerical tolerance and does not classify an interval containing zero as equality.

Callers cannot construct this type directly. Every value has a finite estimate, a finite non-negative absolute error bound, and finite ordered endpoints.

§Examples

use core::assert_matches;
use la_stack::prelude::*;

let left = Vector::<2>::try_new([1.0, 2.0])?;
let right = Vector::<2>::try_new([3.0, 4.0])?;
let certificate = left.dot_with_errbound(&right)?;
assert_eq!(certificate.map(ScalarWithErrorBound::estimate), Some(11.0));
// Preserve None: without a certificate, an exact fallback is needed
// before making a claim about the exact-real result.
let enclosure = certificate.map(|bounded| (bounded.lower_bound(), bounded.upper_bound()));
assert_matches!(enclosure, Some((lower, upper)) if lower <= 11.0 && 11.0 <= upper);

Implementations§

Source§

impl ScalarWithErrorBound

Source

pub const fn estimate(self) -> f64

Return the rounded scalar estimate.

Source

pub const fn absolute_error_bound(self) -> f64

Return the certified absolute error bound.

Source

pub const fn lower_bound(self) -> f64

Return a finite outward-rounded lower bound on the exact-real value.

Source

pub const fn upper_bound(self) -> f64

Return a finite outward-rounded upper bound on the exact-real value.

Trait Implementations§

Source§

impl Clone for ScalarWithErrorBound

Source§

fn clone(&self) -> ScalarWithErrorBound

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ScalarWithErrorBound

Source§

impl Debug for ScalarWithErrorBound

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ScalarWithErrorBound

Source§

fn eq(&self, other: &ScalarWithErrorBound) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScalarWithErrorBound

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.