use crate::ScalarF64;
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct IntegralEstimate<T> {
result: T,
error: f64,
iterations: usize,
evaluations: usize,
}
impl<T: ScalarF64> IntegralEstimate<T> {
#[must_use]
pub const fn result(&self) -> T {
self.result
}
#[must_use]
pub const fn error(&self) -> f64 {
self.error
}
#[must_use]
pub const fn iterations(&self) -> usize {
self.iterations
}
#[must_use]
pub const fn evaluations(&self) -> usize {
self.evaluations
}
}
impl<T: ScalarF64> IntegralEstimate<T> {
pub(crate) fn new() -> Self {
let result = T::zero();
Self {
result,
error: 0.0,
iterations: 0,
evaluations: 0,
}
}
pub(crate) fn with_result(mut self, result: T) -> Self {
self.result = result;
self
}
pub(crate) fn with_error(mut self, error: f64) -> Self {
self.error = error;
self
}
pub(crate) fn with_iterations(mut self, iterations: usize) -> Self {
self.iterations = iterations;
self
}
pub(crate) fn with_evaluations(mut self, evaluations: usize) -> Self {
self.evaluations = evaluations;
self
}
}