diff --git a/src/nodes/eval.rs b/src/nodes/eval.rs index b370b35..f0adfaf 100644 --- a/src/nodes/eval.rs +++ b/src/nodes/eval.rs @@ -141,20 +141,36 @@ impl Operator { impl Function { fn apply_to(&self, n: &mut Float) { match self { - Self::Sqrt => Float::sqrt_mut(n), + Self::AbsoluteValue => Float::abs_mut(n), - Self::Ln => Float::ln_mut(n), + Self::SquareRoot => Float::sqrt_mut(n), + + Self::LogNatural => Float::ln_mut(n), + Self::Log10 => Float::log10_mut(n), Self::Sine => Float::sin_mut(n), Self::ArcSine => Float::asin_mut(n), - Self::Cosine => Float::cos_mut(n), - Self::ArcCosine => Float::acos_mut(n), - Self::Tangent => Float::tan_mut(n), - Self::ArcTangent => Float::atan_mut(n), - Self::Secant => Float::sec_mut(n), Self::CoSecant => Float::csc_mut(n), - Self::Abs => Float::abs_mut(n), + Self::Cosine => Float::cos_mut(n), + Self::ArcCosine => Float::acos_mut(n), + Self::Secant => Float::sec_mut(n), + + Self::Tangent => Float::tan_mut(n), + Self::ArcTangent => Float::atan_mut(n), + Self::CoTangent => Float::cot_mut(n), + + Self::HyperbolicSin => Float::sinh_mut(n), + Self::ArcHyperbolicSin => Float::asinh_mut(n), + Self::HyperbolicCoSecant => Float::csch_mut(n), + + Self::HyperbolicCosine => Float::cosh_mut(n), + Self::ArcHyperbolicCosine => Float::acosh_mut(n), + Self::HyperbolicSecant => Float::csch_mut(n), + + Self::HyperbolicTangent => Float::tanh_mut(n), + Self::ArcHyperbolicTangent => Float::atanh_mut(n), + Self::HyperbolicCoTangent => Float::coth_mut(n), } } } diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index c165052..8970c31 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -74,18 +74,34 @@ pub enum Operator { #[derive(Debug, Copy, Clone, PartialEq)] pub enum Function { - Sqrt, + AbsoluteValue, - Ln, + SquareRoot, + + LogNatural, + Log10, Sine, ArcSine, - Cosine, - ArcCosine, - Tangent, - ArcTangent, - Secant, CoSecant, - Abs, + Cosine, + ArcCosine, + Secant, + + Tangent, + ArcTangent, + CoTangent, + + HyperbolicSin, + ArcHyperbolicSin, + HyperbolicCoSecant, + + HyperbolicCosine, + ArcHyperbolicCosine, + HyperbolicSecant, + + HyperbolicTangent, + ArcHyperbolicTangent, + HyperbolicCoTangent, } diff --git a/src/nodes/parse.rs b/src/nodes/parse.rs index e4fad1c..c5f69e8 100644 --- a/src/nodes/parse.rs +++ b/src/nodes/parse.rs @@ -38,20 +38,36 @@ impl FromStr for Function { type Err = String; fn from_str(s: &str) -> Result { match s { - "sqrt" => Ok(Self::Sqrt), + "abs" => Ok(Self::AbsoluteValue), - "ln" => Ok(Self::Ln), + "sqrt" => Ok(Self::SquareRoot), + + "ln" => Ok(Self::LogNatural), + "log" => Ok(Self::Log10), "sin" => Ok(Self::Sine), "asin" | "arcsin" => Ok(Self::ArcSine), - "cos" => Ok(Self::Cosine), - "acos" | "arccos" => Ok(Self::ArcCosine), - "tan" => Ok(Self::Tangent), - "atan" | "arctan" => Ok(Self::ArcTangent), - "sec" => Ok(Self::Secant), "csc" => Ok(Self::CoSecant), - "abs" => Ok(Self::Abs), + "cos" => Ok(Self::Cosine), + "acos" | "arccos" => Ok(Self::ArcCosine), + "sec" => Ok(Self::Secant), + + "tan" => Ok(Self::Tangent), + "atan" | "arctan" => Ok(Self::ArcTangent), + "cot" => Ok(Self::CoTangent), + + "sinh" => Ok(Self::HyperbolicSin), + "asinh" | "arcsinh" => Ok(Self::ArcHyperbolicSin), + "csch" => Ok(Self::HyperbolicCoSecant), + + "cosh" => Ok(Self::HyperbolicCosine), + "acosh" | "arccosh" => Ok(Self::ArcHyperbolicCosine), + "sech" => Ok(Self::HyperbolicSecant), + + "tanh" => Ok(Self::HyperbolicTangent), + "atanh" | "arctanh" => Ok(Self::ArcHyperbolicTangent), + "coth" => Ok(Self::HyperbolicCoTangent), _ => Err(s.to_owned()), }