diff --git a/src/evaluate/function.rs b/src/evaluate/function.rs index 382165f..ae32c51 100644 --- a/src/evaluate/function.rs +++ b/src/evaluate/function.rs @@ -2,7 +2,6 @@ use std::collections::VecDeque; use crate::parser::Token; use crate::parser::Function; -use crate::parser::Operator; use super::EvalError; @@ -38,31 +37,9 @@ pub fn eval_function(f: &Function, args: &VecDeque) -> Result { return Ok(Token::Quantity(q.acos())); }, Function::Atan => { return Ok(Token::Quantity(q.atan())); }, - Function::Csc => { - return Ok( - Token::Operator( - Operator::Flip, - VecDeque::from(vec!(Token::Quantity(q.sin()))) - ) - ); - }, - Function::Sec => { - return Ok( - Token::Operator( - Operator::Flip, - VecDeque::from(vec!(Token::Quantity(q.cos()))) - ) - ); - }, - Function::Cot => { - return Ok( - Token::Operator( - Operator::Flip, - VecDeque::from(vec!(Token::Quantity(q.tan()))) - ) - ); - }, - + Function::Csc => { return Ok(Token::Quantity(q.csc())); }, + Function::Sec => { return Ok(Token::Quantity(q.sec())); }, + Function::Cot => { return Ok(Token::Quantity(q.cot())); }, Function::Sinh => { return Ok(Token::Quantity(q.sinh())); }, Function::Cosh => { return Ok(Token::Quantity(q.cosh())); }, @@ -71,30 +48,9 @@ pub fn eval_function(f: &Function, args: &VecDeque) -> Result { return Ok(Token::Quantity(q.acosh())); }, Function::Atanh => { return Ok(Token::Quantity(q.atanh())); }, - Function::Csch => { - return Ok( - Token::Operator( - Operator::Flip, - VecDeque::from(vec!(Token::Quantity(q.sinh()))) - ) - ); - }, - Function::Sech => { - return Ok( - Token::Operator( - Operator::Flip, - VecDeque::from(vec!(Token::Quantity(q.cosh()))) - ) - ); - }, - Function::Coth => { - return Ok( - Token::Operator( - Operator::Flip, - VecDeque::from(vec!(Token::Quantity(q.tanh()))) - ) - ); - }, + Function::Csch => { return Ok(Token::Quantity(q.csch())); }, + Function::Sech => { return Ok(Token::Quantity(q.sech())); }, + Function::Coth => { return Ok(Token::Quantity(q.coth())); }, Function::ToBase | Function::NoUnit diff --git a/src/quantity/quantity.rs b/src/quantity/quantity.rs index 9175c37..1c2ec2d 100644 --- a/src/quantity/quantity.rs +++ b/src/quantity/quantity.rs @@ -145,12 +145,18 @@ impl Quantity { quant_foward!(sin); quant_foward!(cos); quant_foward!(tan); + quant_foward!(csc); + quant_foward!(sec); + quant_foward!(cot); quant_foward!(asin); quant_foward!(acos); quant_foward!(atan); quant_foward!(sinh); quant_foward!(cosh); quant_foward!(tanh); + quant_foward!(csch); + quant_foward!(sech); + quant_foward!(coth); quant_foward!(asinh); quant_foward!(acosh); quant_foward!(atanh); diff --git a/src/quantity/scalar/f64base.rs b/src/quantity/scalar/f64base.rs index d272bdf..3901920 100644 --- a/src/quantity/scalar/f64base.rs +++ b/src/quantity/scalar/f64base.rs @@ -60,6 +60,9 @@ impl ScalarBase for F64Base { foward!(sin); foward!(cos); foward!(tan); + foward!(csc); + foward!(sec); + foward!(cot); foward!(asin); foward!(acos); foward!(atan); @@ -67,6 +70,9 @@ impl ScalarBase for F64Base { foward!(sinh); foward!(cosh); foward!(tanh); + foward!(csch); + foward!(sech); + foward!(coth); foward!(asinh); foward!(acosh); foward!(atanh); diff --git a/src/quantity/scalar/floatbase.rs b/src/quantity/scalar/floatbase.rs index 781a90c..37d0d5e 100644 --- a/src/quantity/scalar/floatbase.rs +++ b/src/quantity/scalar/floatbase.rs @@ -138,6 +138,9 @@ impl ScalarBase for FloatBase { foward!(sin); foward!(cos); foward!(tan); + foward!(csc); + foward!(sec); + foward!(cot); foward!(asin); foward!(acos); foward!(atan); @@ -145,6 +148,9 @@ impl ScalarBase for FloatBase { foward!(sinh); foward!(cosh); foward!(tanh); + foward!(csch); + foward!(sech); + foward!(coth); foward!(asinh); foward!(acosh); foward!(atanh); diff --git a/src/quantity/scalar/rationalbase.rs b/src/quantity/scalar/rationalbase.rs index e220511..4270b1b 100644 --- a/src/quantity/scalar/rationalbase.rs +++ b/src/quantity/scalar/rationalbase.rs @@ -121,6 +121,9 @@ impl ScalarBase for RationalBase { cant_do!(sin); cant_do!(cos); cant_do!(tan); + cant_do!(csc); + cant_do!(sec); + cant_do!(cot); cant_do!(asin); cant_do!(acos); cant_do!(atan); @@ -128,6 +131,9 @@ impl ScalarBase for RationalBase { cant_do!(sinh); cant_do!(cosh); cant_do!(tanh); + cant_do!(csch); + cant_do!(sech); + cant_do!(coth); cant_do!(asinh); cant_do!(acosh); cant_do!(atanh); diff --git a/src/quantity/scalar/scalar.rs b/src/quantity/scalar/scalar.rs index a5fe0aa..514e575 100644 --- a/src/quantity/scalar/scalar.rs +++ b/src/quantity/scalar/scalar.rs @@ -41,12 +41,18 @@ pub trait ScalarBase: fn sin(&self) -> Option; fn cos(&self) -> Option; fn tan(&self) -> Option; + fn csc(&self) -> Option; + fn sec(&self) -> Option; + fn cot(&self) -> Option; fn asin(&self) -> Option; fn acos(&self) -> Option; fn atan(&self) -> Option; fn sinh(&self) -> Option; fn cosh(&self) -> Option; fn tanh(&self) -> Option; + fn csch(&self) -> Option; + fn sech(&self) -> Option; + fn coth(&self) -> Option; fn asinh(&self) -> Option; fn acosh(&self) -> Option; fn atanh(&self) -> Option; @@ -206,12 +212,18 @@ impl Scalar { scalar_foward!(sin); scalar_foward!(cos); scalar_foward!(tan); + scalar_foward!(csc); + scalar_foward!(sec); + scalar_foward!(cot); scalar_foward!(asin); scalar_foward!(acos); scalar_foward!(atan); scalar_foward!(sinh); scalar_foward!(cosh); scalar_foward!(tanh); + scalar_foward!(csch); + scalar_foward!(sech); + scalar_foward!(coth); scalar_foward!(asinh); scalar_foward!(acosh); scalar_foward!(atanh);