pub struct PrecisionContext {
pub precision: f64,
pub error_bounds: f64,
pub significant_digits: u32,
pub precision_loss_sources: Vec<PrecisionLossSource>,
pub condition_number: Option<f64>,
pub is_stable: bool,
pub last_updated: Instant,
}
Expand description
Precision context for tracking numerical accuracy
Fields§
§precision: f64
Current precision estimate (in terms of significant digits)
error_bounds: f64
Error bounds (relative error)
significant_digits: u32
Number of significant digits
precision_loss_sources: Vec<PrecisionLossSource>
Operations that contributed to precision loss
condition_number: Option<f64>
Condition number estimate
is_stable: bool
Whether the computation is numerically stable
last_updated: Instant
Timestamp of last update
Implementations§
Source§impl PrecisionContext
impl PrecisionContext
pub fn new() -> Self
Sourcepub fn with_precision(precision: f64) -> Self
pub fn with_precision(precision: f64) -> Self
Create a new precision context with given precision
Sourcepub fn single_precision() -> Self
pub fn single_precision() -> Self
Create a precision context for single precision (f32)
Sourcepub fn double_precision() -> Self
pub fn double_precision() -> Self
Create a precision context for double precision (f64)
Sourcepub fn extended_precision() -> Self
pub fn extended_precision() -> Self
Create a precision context for extended precision
Sourcepub fn update_precision(&mut self, newprecision: f64, operation: &str)
pub fn update_precision(&mut self, newprecision: f64, operation: &str)
Update precision after an operation
Sourcepub fn record_precision_loss(
&mut self,
operation: &str,
loss: f64,
description: Option<String>,
location: Option<String>,
)
pub fn record_precision_loss( &mut self, operation: &str, loss: f64, description: Option<String>, location: Option<String>, )
Record precision loss from a specific operation
Sourcepub fn set_condition_number(&mut self, cond: f64)
pub fn set_condition_number(&mut self, cond: f64)
Set condition number estimate
Sourcepub fn total_precision_loss(&self) -> f64
pub fn total_precision_loss(&self) -> f64
Get the total precision loss
Sourcepub fn worst_severity(&self) -> Option<PrecisionLossSeverity>
pub fn worst_severity(&self) -> Option<PrecisionLossSeverity>
Get the worst precision loss severity
Sourcepub fn has_acceptable_precision(&self, minprecision: f64) -> bool
pub fn has_acceptable_precision(&self, minprecision: f64) -> bool
Check if the computation has acceptable precision
Sourcepub fn check_acceptable(&self, threshold: f64) -> Option<PrecisionWarning>
pub fn check_acceptable(&self, threshold: f64) -> Option<PrecisionWarning>
Generate precision warning if necessary
Sourcepub fn check_precision_warning(
&self,
minprecision: f64,
) -> Option<PrecisionWarning>
pub fn check_precision_warning( &self, minprecision: f64, ) -> Option<PrecisionWarning>
Check if precision falls below a minimum threshold and return a warning
Trait Implementations§
Source§impl Clone for PrecisionContext
impl Clone for PrecisionContext
Source§fn clone(&self) -> PrecisionContext
fn clone(&self) -> PrecisionContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PrecisionContext
impl Debug for PrecisionContext
Auto Trait Implementations§
impl Freeze for PrecisionContext
impl RefUnwindSafe for PrecisionContext
impl Send for PrecisionContext
impl Sync for PrecisionContext
impl Unpin for PrecisionContext
impl UnwindSafe for PrecisionContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more