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)
 
void bvisit (const Piecewise &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)
 
void bvisit (const Piecewise &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 244 of file visitor.cpp.

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

◆ bvisit() [1/13]

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

Definition at line 247 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/13]

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

Definition at line 246 of file visitor.cpp.

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

◆ bvisit() [3/13]

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

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

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

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

Definition at line 248 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/13]

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

Definition at line 264 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/13]

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

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

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

Definition at line 250 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/13]

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

Definition at line 265 of file visitor.cpp.

205{
206 auto branch_cond_pairs = x.get_vec();
207 PiecewiseVec new_pairs;
208 for (const auto &branch_cond : branch_cond_pairs) {
209 auto branch = branch_cond.first;
210 auto cond = branch_cond.second;
211 auto new_branch = apply(branch);
212 auto new_cond = apply(cond);
213 if (!is_a_Boolean(*new_cond)) {
214 new_cond = Eq(new_cond, boolTrue);
215 }
216 new_pairs.push_back(
217 {new_branch, rcp_static_cast<const Boolean>(new_cond)});
218 }
219 result_ = piecewise(new_pairs);
220}
RCP< const Boolean > Eq(const RCP< const Basic > &lhs)
Returns the canonicalized Equality object from a single argument.
Definition: logic.cpp:653

◆ bvisit() [12/13]

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

Definition at line 249 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/13]

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

Definition at line 253 of file visitor.h.

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

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: