opensrdk_symbolic_computation/expression/transcendental_expression/functions/
cos.rs

1use std::collections::HashMap;
2
3use crate::{BracketsLevel, Expression, TranscendentalExpression};
4
5impl Expression {
6    pub fn cos(self) -> Self {
7        if let Expression::Constant(mut v) = self {
8            v.elems_mut().into_iter().for_each(|v| *v = v.cos());
9            return v.into();
10        }
11
12        TranscendentalExpression::Cos(self.into()).into()
13    }
14}
15
16impl TranscendentalExpression {
17    pub(crate) fn tex_code_cos(arg: &Box<Expression>, symbols: &HashMap<&str, &str>) -> String {
18        format!(
19            r"\cos\left({}\right)",
20            arg._tex_code(symbols, BracketsLevel::None)
21        )
22    }
23}