don't partially regen derivative_cache if derivative is disabled
This commit is contained in:
parent
21e56cac4d
commit
25c4285fc0
@ -130,20 +130,24 @@ impl FunctionEntry {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if self.derivative_cache.is_some() {
|
if self.derivative_cache.is_some() {
|
||||||
let derivative_cache = self.derivative_cache.as_ref().unwrap();
|
if self.derivative {
|
||||||
|
let derivative_cache = self.derivative_cache.as_ref().unwrap();
|
||||||
|
|
||||||
self.derivative_cache = Some(
|
self.derivative_cache = Some(
|
||||||
(0..=self.pixel_width)
|
(0..=self.pixel_width)
|
||||||
.map(|x| (x as f64 / resolution as f64) + min_x)
|
.map(|x| (x as f64 / resolution as f64) + min_x)
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
if let Some(i) = x_data.get_index(x) {
|
if let Some(i) = x_data.get_index(x) {
|
||||||
derivative_cache[i]
|
derivative_cache[i]
|
||||||
} else {
|
} else {
|
||||||
Value::new(x, self.function.derivative(x))
|
Value::new(x, self.function.derivative(x))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
self.derivative_cache = None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.back_cache = None;
|
self.back_cache = None;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user