From cda3853a0188673183569343a84e88f0e3b8d314 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 10 Mar 2022 08:49:17 -0500 Subject: [PATCH] rename BackingFunction::derivative to BackingFunction::get_derivative_1 --- src/function.rs | 9 +++++---- src/parsing.rs | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/function.rs b/src/function.rs index ae47da9..630ce8e 100644 --- a/src/function.rs +++ b/src/function.rs @@ -138,7 +138,7 @@ impl FunctionEntry { if let Some(i) = x_data.get_index(x) { derivative_cache[i] } else { - Value::new(x, self.function.derivative(x)) + Value::new(x, self.function.get_derivative_1(x)) } }) .collect(); @@ -175,7 +175,7 @@ impl FunctionEntry { self.output.derivative = Some( (0..self.pixel_width) .map(|x| (x as f64 / resolution as f64) + self.min_x) - .map(|x| Value::new(x, self.function.derivative(x))) + .map(|x| Value::new(x, self.function.get_derivative_1(x))) .collect(), ); } @@ -311,7 +311,7 @@ impl FunctionEntry { let mut x2: f64; let mut fail: bool = false; loop { - x2 = x1 - (self.function.get(x1) / self.function.derivative(x1)); + x2 = x1 - (self.function.get(x1) / self.function.get_derivative_1(x1)); if !(self.min_x..self.max_x).contains(&x2) { fail = true; break; @@ -365,7 +365,8 @@ impl FunctionEntry { let mut fail: bool = false; loop { x2 = x1 - - (self.function.derivative(x1) / self.function.get_derivative_2(x1)); + - (self.function.get_derivative_1(x1) + / self.function.get_derivative_2(x1)); if !(self.min_x..self.max_x).contains(&x2) { fail = true; break; diff --git a/src/parsing.rs b/src/parsing.rs index eef40eb..a5fea21 100644 --- a/src/parsing.rs +++ b/src/parsing.rs @@ -34,7 +34,9 @@ impl BackingFunction { pub fn get(&self, x: f64) -> f64 { self.function.eval(&[x]).unwrap_or(f64::NAN) } - pub fn derivative(&self, x: f64) -> f64 { self.derivative_1.eval(&[x]).unwrap_or(f64::NAN) } + pub fn get_derivative_1(&self, x: f64) -> f64 { + self.derivative_1.eval(&[x]).unwrap_or(f64::NAN) + } pub fn get_derivative_2(&self, x: f64) -> f64 { self.derivative_2.eval(&[x]).unwrap_or(f64::NAN)