mirror of https://github.com/rm-dr/daisy
Fixed trig functions
parent
00a421756d
commit
4dfaf2b863
|
@ -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<Token>) -> Result<Token, Eval
|
|||
Function::Acos => { 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<Token>) -> Result<Token, Eval
|
|||
Function::Acosh => { 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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -41,12 +41,18 @@ pub trait ScalarBase:
|
|||
fn sin(&self) -> Option<Self>;
|
||||
fn cos(&self) -> Option<Self>;
|
||||
fn tan(&self) -> Option<Self>;
|
||||
fn csc(&self) -> Option<Self>;
|
||||
fn sec(&self) -> Option<Self>;
|
||||
fn cot(&self) -> Option<Self>;
|
||||
fn asin(&self) -> Option<Self>;
|
||||
fn acos(&self) -> Option<Self>;
|
||||
fn atan(&self) -> Option<Self>;
|
||||
fn sinh(&self) -> Option<Self>;
|
||||
fn cosh(&self) -> Option<Self>;
|
||||
fn tanh(&self) -> Option<Self>;
|
||||
fn csch(&self) -> Option<Self>;
|
||||
fn sech(&self) -> Option<Self>;
|
||||
fn coth(&self) -> Option<Self>;
|
||||
fn asinh(&self) -> Option<Self>;
|
||||
fn acosh(&self) -> Option<Self>;
|
||||
fn atanh(&self) -> Option<Self>;
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue