opensrdk_symbolic_computation/expression/transcendental_expression/functions/
exp.rs1use std::collections::HashMap;
2
3use crate::{Expression, ExpressionArray, TranscendentalExpression};
4
5impl Expression {
6 pub fn exp(self) -> Self {
7 if let Expression::PartialVariable(v) = &self {
8 return Expression::PartialVariable(ExpressionArray::from_factory(
9 v.sizes().to_vec(),
10 |indices| TranscendentalExpression::Exp(v[indices].clone().into()).into(),
11 ));
12 }
13 if let Expression::Constant(mut v) = self {
14 v.elems_mut().into_iter().for_each(|v| *v = v.exp());
15 return v.into();
16 }
17
18 TranscendentalExpression::Exp(self.into()).into()
19 }
20}
21
22impl TranscendentalExpression {
23 pub(crate) fn tex_code_exp(arg: &Box<Expression>, symbols: &HashMap<&str, &str>) -> String {
24 format!(
25 r"\exp{{{}}}",
26 arg._tex_code(symbols, crate::BracketsLevel::ForOperation)
27 )
28 }
29}