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

Public Member Functions

 EvalVisitor (unsigned long bits)
 
void bvisit (const Number &x)
 
void bvisit (const ComplexBase &x)
 
void bvisit (const Constant &x)
 
void bvisit (const NumberWrapper &x)
 
void bvisit (const FunctionWrapper &x)
 
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)
 
- 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)
 

Protected Attributes

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

Detailed Description

Definition at line 54 of file eval.cpp.

Constructor & Destructor Documentation

◆ EvalVisitor()

SymEngine::EvalVisitor::EvalVisitor ( unsigned long  bits)
inline

Definition at line 60 of file eval.cpp.

60: bits(bits) {}

Member Function Documentation

◆ apply()

RCP< const Basic > SymEngine::TransformVisitor::apply ( const RCP< const Basic > &  x)
virtual

Reimplemented from SymEngine::TransformVisitor.

Definition at line 243 of file visitor.cpp.

143{
144 x->accept(*this);
145 return result_;
146}

◆ bvisit() [1/12]

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/12]

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/12]

void SymEngine::EvalVisitor::bvisit ( const ComplexBase x)
inline

Definition at line 67 of file eval.cpp.

68 {
69 result_ = evalf_numeric(x, bits, false);
70 }

◆ bvisit() [4/12]

void SymEngine::EvalVisitor::bvisit ( const Constant x)
inline

Definition at line 71 of file eval.cpp.

72 {
73 result_ = evalf_numeric(x, bits, true);
74 }

◆ bvisit() [5/12]

void SymEngine::EvalVisitor::bvisit ( const FunctionWrapper x)
inline

Definition at line 79 of file eval.cpp.

80 {
81 result_ = x.eval(bits)->rcp_from_this();
82 }

◆ bvisit() [6/12]

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}
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352

◆ bvisit() [7/12]

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() [8/12]

void SymEngine::EvalVisitor::bvisit ( const Number x)
inline

Definition at line 63 of file eval.cpp.

64 {
65 result_ = evalf_numeric(x, bits, true);
66 }

◆ bvisit() [9/12]

void SymEngine::EvalVisitor::bvisit ( const NumberWrapper x)
inline

Definition at line 75 of file eval.cpp.

76 {
77 result_ = x.eval(bits)->rcp_from_this();
78 }

◆ bvisit() [10/12]

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() [11/12]

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() [12/12]

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 }

Field Documentation

◆ bits

unsigned long SymEngine::EvalVisitor::bits
protected

Definition at line 57 of file eval.cpp.


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