#[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
impl ScalarWithErrorBound
Sourcepub const fn absolute_error_bound(self) -> f64
pub const fn absolute_error_bound(self) -> f64
Return the certified absolute error bound.
Sourcepub const fn lower_bound(self) -> f64
pub const fn lower_bound(self) -> f64
Return a finite outward-rounded lower bound on the exact-real value.
Sourcepub const fn upper_bound(self) -> f64
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
impl Clone for ScalarWithErrorBound
Source§fn clone(&self) -> ScalarWithErrorBound
fn clone(&self) -> ScalarWithErrorBound
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more