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