This commit is contained in:
Simon Gardling
2022-03-07 13:26:25 -05:00
parent d48b94c1d2
commit 8524d5f57e
4 changed files with 28 additions and 46 deletions

View File

@@ -239,6 +239,7 @@ impl FunctionEntry {
let step = (self.integral_min_x - self.integral_max_x).abs() / (self.integral_num as f64);
let mut last_positive: Option<bool> = None;
let mut area: f64 = 0.0;
let data2: Vec<(f64, f64, f64)> = (0..self.integral_num)
.map(|e| {
@@ -257,6 +258,10 @@ impl FunctionEntry {
RiemannSum::Middle => (self.run_func(left_x) + self.run_func(right_x)) / 2.0,
};
if last_positive.is_none() {
last_positive = Some(x.is_sign_positive());
}
if !y.is_nan() {
area += y * step;
}
@@ -311,6 +316,8 @@ impl FunctionEntry {
self
}
// Invalidates the derivative cache. This would be used in the case of a change in the nth_derivative
#[allow(dead_code)]
pub fn invalidate_derivative_cache(&mut self) { self.derivative_cache = None; }
}