Loading...
Searching...
No Matches
SymEngine::RewriteAsExp Class Reference
+ Inheritance diagram for SymEngine::RewriteAsExp:
+ Collaboration diagram for SymEngine::RewriteAsExp:

Public Member Functions

void bvisit (const Sin &x)
 
void bvisit (const Cos &x)
 
void bvisit (const Tan &x)
 
void bvisit (const Cot &x)
 
void bvisit (const Csc &x)
 
void bvisit (const Sec &x)
 
void bvisit (const Sinh &x)
 
void bvisit (const Cosh &x)
 
void bvisit (const Tanh &x)
 
void bvisit (const Csch &x)
 
void bvisit (const Sech &x)
 
void bvisit (const Coth &x)
 
void bvisit (const Basic &x)
 
void bvisit (const Add &x)
 
void bvisit (const Mul &x)
 
void bvisit (const Pow &x)
 
void bvisit (const OneArgFunction &x)
 
template<class T >
void bvisit (const TwoArgBasic< T > &x)
 
void bvisit (const MultiArgFunction &x)
 
- Public Member Functions inherited from SymEngine::TransformVisitor
virtual RCP< const Basicapply (const RCP< const Basic > &x)
 
void bvisit (const Basic &x)
 
void bvisit (const Add &x)
 
void bvisit (const Mul &x)
 
void bvisit (const Pow &x)
 
void bvisit (const OneArgFunction &x)
 
template<class T >
void bvisit (const TwoArgBasic< T > &x)
 
void bvisit (const MultiArgFunction &x)
 

Additional Inherited Members

- Protected Attributes inherited from SymEngine::TransformVisitor
RCP< const Basicresult_
 

Detailed Description

Definition at line 7 of file rewrite.cpp.

Constructor & Destructor Documentation

◆ RewriteAsExp()

SymEngine::RewriteAsExp::RewriteAsExp ( )
inline

Definition at line 12 of file rewrite.cpp.

12: BaseVisitor<RewriteAsExp, TransformVisitor>() {}

Member Function Documentation

◆ bvisit() [1/19]

void SymEngine::TransformVisitor::bvisit ( const Add x)

Definition at line 246 of file visitor.cpp.

154{
155 vec_basic newargs;
156 for (const auto &a : x.get_args()) {
157 newargs.push_back(apply(a));
158 }
159 result_ = add(newargs);
160}
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
Definition: add.cpp:425
T push_back(T... args)

◆ bvisit() [2/19]

void SymEngine::TransformVisitor::bvisit ( const Basic x)

Definition at line 245 of file visitor.cpp.

149{
150 result_ = x.rcp_from_this();
151}

◆ bvisit() [3/19]

void SymEngine::RewriteAsExp::bvisit ( const Cos x)
inline

Definition at line 24 of file rewrite.cpp.

25 {
26 auto farg = x.get_arg();
27 auto newarg = apply(farg);
28 auto expo = mul(I, newarg);
29 auto a = exp(expo);
30 auto b = exp(neg(expo));
31 result_ = div(add(a, b), integer(2));
32 }
RCP< const Basic > div(const RCP< const Basic > &a, const RCP< const Basic > &b)
Division.
Definition: mul.cpp:431
RCP< const Basic > exp(const RCP< const Basic > &x)
Returns the natural exponential function E**x = pow(E, x)
Definition: pow.cpp:271
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)
Definition: integer.h:200
RCP< const Basic > neg(const RCP< const Basic > &a)
Negation.
Definition: mul.cpp:443

◆ bvisit() [4/19]

void SymEngine::RewriteAsExp::bvisit ( const Cosh x)
inline

Definition at line 81 of file rewrite.cpp.

82 {
83 auto farg = x.get_arg();
84 auto newarg = apply(farg);
85 result_ = div(add(exp(newarg), exp(neg(newarg))), integer(2));
86 }

◆ bvisit() [5/19]

void SymEngine::RewriteAsExp::bvisit ( const Cot x)
inline

Definition at line 44 of file rewrite.cpp.

45 {
46 auto farg = x.get_arg();
47 auto newarg = apply(farg);
48 auto expo = mul(I, newarg);
49 auto a = exp(expo);
50 auto b = exp(neg(expo));
51 result_ = div(mul(I, add(a, b)), sub(a, b));
52 }
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
Definition: add.cpp:495

◆ bvisit() [6/19]

void SymEngine::RewriteAsExp::bvisit ( const Coth x)
inline

Definition at line 115 of file rewrite.cpp.

116 {
117 auto farg = x.get_arg();
118 auto newarg = apply(farg);
119 auto pos_exp = exp(newarg);
120 auto neg_exp = exp(neg(newarg));
121 result_ = div(add(pos_exp, neg_exp), sub(pos_exp, neg_exp));
122 }

◆ bvisit() [7/19]

void SymEngine::RewriteAsExp::bvisit ( const Csc x)
inline

Definition at line 54 of file rewrite.cpp.

55 {
56 auto farg = x.get_arg();
57 auto newarg = apply(farg);
58 auto expo = mul(I, newarg);
59 auto a = exp(expo);
60 auto b = exp(neg(expo));
61 result_ = div(mul(I, integer(2)), sub(a, b));
62 }

◆ bvisit() [8/19]

void SymEngine::RewriteAsExp::bvisit ( const Csch x)
inline

Definition at line 97 of file rewrite.cpp.

98 {
99 auto farg = x.get_arg();
100 auto newarg = apply(farg);
101 auto pos_exp = exp(newarg);
102 auto neg_exp = exp(neg(newarg));
103 result_ = div(integer(2), sub(pos_exp, neg_exp));
104 }

◆ bvisit() [9/19]

void SymEngine::TransformVisitor::bvisit ( const Mul x)

Definition at line 247 of file visitor.cpp.

163{
164 vec_basic newargs;
165 for (const auto &a : x.get_args()) {
166 newargs.push_back(apply(a));
167 }
168 result_ = mul(newargs);
169}

◆ bvisit() [10/19]

void SymEngine::TransformVisitor::bvisit ( const MultiArgFunction x)

Definition at line 263 of file visitor.cpp.

194{
195 auto fargs = x.get_args();
196 vec_basic newargs;
197 for (const auto &a : fargs) {
198 newargs.push_back(apply(a));
199 }
200 auto nbarg = x.create(newargs);
201 result_ = nbarg;
202}

◆ bvisit() [11/19]

void SymEngine::TransformVisitor::bvisit ( const OneArgFunction x)

Definition at line 249 of file visitor.cpp.

183{
184 auto farg = x.get_arg();
185 auto newarg = apply(farg);
186 if (eq(*newarg, *farg)) {
187 result_ = x.rcp_from_this();
188 } else {
189 result_ = x.create(newarg);
190 }
191}
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21

◆ bvisit() [12/19]

void SymEngine::TransformVisitor::bvisit ( const Pow x)

Definition at line 248 of file visitor.cpp.

172{
173 auto base_ = x.get_base(), exp_ = x.get_exp();
174 auto newarg1 = apply(base_), newarg2 = apply(exp_);
175 if (base_ != newarg1 or exp_ != newarg2) {
176 result_ = pow(newarg1, newarg2);
177 } else {
178 result_ = x.rcp_from_this();
179 }
180}
T pow(T... args)

◆ bvisit() [13/19]

void SymEngine::RewriteAsExp::bvisit ( const Sec x)
inline

Definition at line 64 of file rewrite.cpp.

65 {
66 auto farg = x.get_arg();
67 auto newarg = apply(farg);
68 auto expo = mul(I, newarg);
69 auto a = exp(expo);
70 auto b = exp(neg(expo));
71 result_ = div(integer(2), add(a, b));
72 }

◆ bvisit() [14/19]

void SymEngine::RewriteAsExp::bvisit ( const Sech x)
inline

Definition at line 106 of file rewrite.cpp.

107 {
108 auto farg = x.get_arg();
109 auto newarg = apply(farg);
110 auto pos_exp = exp(newarg);
111 auto neg_exp = exp(neg(newarg));
112 result_ = div(integer(2), add(pos_exp, neg_exp));
113 }

◆ bvisit() [15/19]

void SymEngine::RewriteAsExp::bvisit ( const Sin x)
inline

Definition at line 14 of file rewrite.cpp.

15 {
16 auto farg = x.get_arg();
17 auto newarg = apply(farg);
18 auto expo = mul(I, newarg);
19 auto a = exp(expo);
20 auto b = exp(neg(expo));
21 result_ = div(sub(a, b), mul(integer(2), I));
22 }

◆ bvisit() [16/19]

void SymEngine::RewriteAsExp::bvisit ( const Sinh x)
inline

Definition at line 74 of file rewrite.cpp.

75 {
76 auto farg = x.get_arg();
77 auto newarg = apply(farg);
78 result_ = div(sub(exp(newarg), exp(neg(newarg))), integer(2));
79 }

◆ bvisit() [17/19]

void SymEngine::RewriteAsExp::bvisit ( const Tan x)
inline

Definition at line 34 of file rewrite.cpp.

35 {
36 auto farg = x.get_arg();
37 auto newarg = apply(farg);
38 auto expo = mul(I, newarg);
39 auto a = exp(expo);
40 auto b = exp(neg(expo));
41 result_ = div(sub(a, b), mul(I, add(a, b)));
42 }

◆ bvisit() [18/19]

void SymEngine::RewriteAsExp::bvisit ( const Tanh x)
inline

Definition at line 88 of file rewrite.cpp.

89 {
90 auto farg = x.get_arg();
91 auto newarg = apply(farg);
92 auto pos_exp = exp(newarg);
93 auto neg_exp = exp(neg(newarg));
94 result_ = div(sub(pos_exp, neg_exp), add(pos_exp, neg_exp));
95 }

◆ bvisit() [19/19]

template<class T >
void SymEngine::TransformVisitor::bvisit ( const TwoArgBasic< T > &  x)
inline

Definition at line 252 of file visitor.h.

253 {
254 auto farg1 = x.get_arg1(), farg2 = x.get_arg2();
255 auto newarg1 = apply(farg1), newarg2 = apply(farg2);
256 if (farg1 != newarg1 or farg2 != newarg2) {
257 result_ = x.create(newarg1, newarg2);
258 } else {
259 result_ = x.rcp_from_this();
260 }
261 }

The documentation for this class was generated from the following file: