remove some explicit inline declarations
This commit is contained in:
parent
6b500292a3
commit
6d4bd0b8ae
@ -35,7 +35,6 @@ pub struct MathApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MathApp {
|
impl Default for MathApp {
|
||||||
#[inline]
|
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let def_min_x = -10.0;
|
let def_min_x = -10.0;
|
||||||
let def_max_x = 10.0;
|
let def_max_x = 10.0;
|
||||||
|
|||||||
@ -11,13 +11,10 @@ pub struct FunctionOutput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FunctionOutput {
|
impl FunctionOutput {
|
||||||
#[inline]
|
|
||||||
pub fn new(back: Vec<Value>, front: Option<(Vec<Bar>, f64)>) -> Self { Self { back, front } }
|
pub fn new(back: Vec<Value>, front: Option<(Vec<Bar>, f64)>) -> Self { Self { back, front } }
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_back(&self) -> Vec<Value> { self.back.clone() }
|
pub fn get_back(&self) -> Vec<Value> { self.back.clone() }
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_front(&self) -> (Vec<Bar>, f64) {
|
pub fn get_front(&self) -> (Vec<Bar>, f64) {
|
||||||
match &self.front {
|
match &self.front {
|
||||||
Some(x) => (x.0.clone(), x.1),
|
Some(x) => (x.0.clone(), x.1),
|
||||||
@ -25,7 +22,6 @@ impl FunctionOutput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn has_integral(&self) -> bool { self.front.is_some() }
|
pub fn has_integral(&self) -> bool { self.front.is_some() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,10 +101,8 @@ impl Function {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Runs the internal function to get values
|
// Runs the internal function to get values
|
||||||
#[inline]
|
|
||||||
fn run_func(&self, x: f64) -> f64 { (self.function)(x) }
|
fn run_func(&self, x: f64) -> f64 { (self.function)(x) }
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn update(
|
pub fn update(
|
||||||
&mut self, func_str: String, integral: bool, integral_min_x: Option<f64>,
|
&mut self, func_str: String, integral: bool, integral_min_x: Option<f64>,
|
||||||
integral_max_x: Option<f64>, integral_num: Option<usize>,
|
integral_max_x: Option<f64>, integral_num: Option<usize>,
|
||||||
@ -159,7 +153,6 @@ impl Function {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn update_bounds(&mut self, min_x: f64, max_x: f64, pixel_width: usize) {
|
pub fn update_bounds(&mut self, min_x: f64, max_x: f64, pixel_width: usize) {
|
||||||
if pixel_width != self.pixel_width {
|
if pixel_width != self.pixel_width {
|
||||||
self.back_cache = None;
|
self.back_cache = None;
|
||||||
@ -170,7 +163,6 @@ impl Function {
|
|||||||
&& self.back_cache.is_some()
|
&& self.back_cache.is_some()
|
||||||
&& false
|
&& false
|
||||||
{
|
{
|
||||||
println!("rebuilding cache");
|
|
||||||
let range_new: f64 = max_x.abs() + min_x.abs();
|
let range_new: f64 = max_x.abs() + min_x.abs();
|
||||||
|
|
||||||
let resolution: f64 = (self.pixel_width as f64 / range_new) as f64;
|
let resolution: f64 = (self.pixel_width as f64 / range_new) as f64;
|
||||||
@ -207,15 +199,12 @@ impl Function {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_step(&self) -> f64 {
|
pub fn get_step(&self) -> f64 {
|
||||||
(self.integral_min_x - self.integral_max_x).abs() / (self.integral_num as f64)
|
(self.integral_min_x - self.integral_max_x).abs() / (self.integral_num as f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn is_integral(&self) -> bool { self.integral }
|
pub fn is_integral(&self) -> bool { self.integral }
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn run(&mut self) -> FunctionOutput {
|
pub fn run(&mut self) -> FunctionOutput {
|
||||||
let front_values: Vec<Value> = match self.back_cache.is_some() {
|
let front_values: Vec<Value> = match self.back_cache.is_some() {
|
||||||
true => self.back_cache.as_ref().expect("").clone(),
|
true => self.back_cache.as_ref().expect("").clone(),
|
||||||
|
|||||||
@ -5,7 +5,6 @@ EXTREMELY Janky function that tries to put asterisks in the proper places to be
|
|||||||
One limitation though, variables with multiple characters like `pi` cannot be multiplied (like `pipipipi` won't result in `pi*pi*pi*pi`). But that's such a niche use case (and that same thing could be done by using exponents) that it doesn't really matter.
|
One limitation though, variables with multiple characters like `pi` cannot be multiplied (like `pipipipi` won't result in `pi*pi*pi*pi`). But that's such a niche use case (and that same thing could be done by using exponents) that it doesn't really matter.
|
||||||
In the future I may want to completely rewrite this or implement this natively into mevel-rs (which would probably be good to do)
|
In the future I may want to completely rewrite this or implement this natively into mevel-rs (which would probably be good to do)
|
||||||
*/
|
*/
|
||||||
#[inline]
|
|
||||||
pub fn add_asterisks(function_in: String) -> String {
|
pub fn add_asterisks(function_in: String) -> String {
|
||||||
let function = function_in.replace("log10(", "log(").replace("pi", "π"); // pi -> π and log10 -> log
|
let function = function_in.replace("log10(", "log(").replace("pi", "π"); // pi -> π and log10 -> log
|
||||||
let valid_variables: Vec<char> = "xeπ".chars().collect();
|
let valid_variables: Vec<char> = "xeπ".chars().collect();
|
||||||
@ -79,7 +78,6 @@ pub fn add_asterisks(function_in: String) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tests function to make sure it's able to be parsed. Returns the string of the Error produced, or an empty string if it runs successfully.
|
// Tests function to make sure it's able to be parsed. Returns the string of the Error produced, or an empty string if it runs successfully.
|
||||||
#[inline]
|
|
||||||
pub fn test_func(function_string: String) -> String {
|
pub fn test_func(function_string: String) -> String {
|
||||||
// Factorials do not work, and it would be really difficult to make them work
|
// Factorials do not work, and it would be really difficult to make them work
|
||||||
if function_string.contains('!') {
|
if function_string.contains('!') {
|
||||||
@ -110,7 +108,6 @@ pub fn test_func(function_string: String) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rounds f64 to specific number of digits
|
// Rounds f64 to specific number of digits
|
||||||
#[inline]
|
|
||||||
pub fn digits_precision(x: f64, digits: usize) -> f64 {
|
pub fn digits_precision(x: f64, digits: usize) -> f64 {
|
||||||
let large_number: f64 = 10.0_f64.powf(digits as f64);
|
let large_number: f64 = 10.0_f64.powf(digits as f64);
|
||||||
(x * large_number).round() / large_number
|
(x * large_number).round() / large_number
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user