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

Public Member Functions

 InvertComplexVisitor (RCP< const Set > gY, RCP< const Dummy > nD, RCP< const Symbol > sym, RCP< const Set > domain)
 
void bvisit (const Basic &x)
 
void bvisit (const Add &x)
 
void bvisit (const Mul &x)
 
void bvisit (const Pow &x)
 
RCP< const Setapply (const Basic &b)
 

Protected Attributes

RCP< const Setresult_
 
RCP< const SetgY_
 
RCP< const DummynD_
 
RCP< const Symbolsym_
 
RCP< const Setdomain_
 

Detailed Description

Definition at line 357 of file solve.cpp.

Constructor & Destructor Documentation

◆ InvertComplexVisitor()

SymEngine::InvertComplexVisitor::InvertComplexVisitor ( RCP< const Set gY,
RCP< const Dummy nD,
RCP< const Symbol sym,
RCP< const Set domain 
)
inline

Definition at line 367 of file solve.cpp.

369 : gY_(gY), nD_(nD), sym_(sym), domain_(domain)
370 {
371 }

Member Function Documentation

◆ apply()

RCP< const Set > SymEngine::InvertComplexVisitor::apply ( const Basic b)
inline

Definition at line 448 of file solve.cpp.

449 {
450 result_ = gY_;
451 b.accept(*this);
452 return set_intersection({domain_, result_});
453 }
T set_intersection(T... args)

◆ bvisit() [1/4]

void SymEngine::InvertComplexVisitor::bvisit ( const Add x)
inline

Definition at line 378 of file solve.cpp.

379 {
380 vec_basic f1X, f2X;
381 for (auto &elem : x.get_args()) {
382 if (has_symbol(*elem, *sym_)) {
383 f1X.push_back(elem);
384 } else {
385 f2X.push_back(elem);
386 }
387 }
388 auto depX = add(f1X), indepX = add(f2X);
389 if (not eq(*indepX, *zero)) {
390 gY_ = imageset(nD_, sub(nD_, indepX), gY_);
391 result_ = apply(*depX);
392 } else {
393 result_ = gY_;
394 }
395 }
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
Definition: add.cpp:495
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/4]

void SymEngine::InvertComplexVisitor::bvisit ( const Basic x)
inline

Definition at line 373 of file solve.cpp.

374 {
375 result_ = gY_;
376 }

◆ bvisit() [3/4]

void SymEngine::InvertComplexVisitor::bvisit ( const Mul x)
inline

Definition at line 397 of file solve.cpp.

398 {
399 vec_basic f1X, f2X;
400 for (auto &elem : x.get_args()) {
401 if (has_symbol(*elem, *sym_)) {
402 f1X.push_back(elem);
403 } else {
404 f2X.push_back(elem);
405 }
406 }
407 auto depX = mul(f1X), indepX = mul(f2X);
408 if (not eq(*indepX, *one)) {
409 if (eq(*indepX, *NegInf) or eq(*indepX, *Inf)
410 or eq(*indepX, *ComplexInf)) {
411 result_ = emptyset();
412 } else {
413 gY_ = imageset(nD_, div(nD_, indepX), gY_);
414 result_ = apply(*depX);
415 }
416 } else {
417 result_ = gY_;
418 }
419 }
RCP< const Basic > div(const RCP< const Basic > &a, const RCP< const Basic > &b)
Division.
Definition: mul.cpp:431
RCP< const EmptySet > emptyset()
Definition: sets.h:590
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352

◆ bvisit() [4/4]

void SymEngine::InvertComplexVisitor::bvisit ( const Pow x)
inline

Definition at line 421 of file solve.cpp.

422 {
423 if (eq(*x.get_base(), *E) and is_a<FiniteSet>(*gY_)) {
424 set_set inv;
425 for (const auto &elem :
426 down_cast<const FiniteSet &>(*gY_).get_container()) {
427 if (eq(*elem, *zero))
428 continue;
429 RCP<const Basic> re, im;
430 as_real_imag(elem, outArg(re), outArg(im));
431 auto logabs = log(add(mul(re, re), mul(im, im)));
432 auto logarg = atan2(im, re);
433 inv.insert(imageset(
434 nD_,
435 add(mul(add(mul({integer(2), nD_, pi}), logarg), I),
436 div(logabs, integer(2))),
437 interval(NegInf, Inf, true,
438 true))); // TODO : replace interval(-oo,oo) with
439 // Set of Integers once Class for Range is implemented.
440 }
441 gY_ = set_union(inv);
442 apply(*x.get_exp());
443 return;
444 }
445 result_ = gY_;
446 }
RCP< const Basic > atan2(const RCP< const Basic > &num, const RCP< const Basic > &den)
Canonicalize ATan2:
Definition: functions.cpp:1614
RCP< const Basic > log(const RCP< const Basic > &arg)
Returns the Natural Logarithm from argument arg
Definition: functions.cpp:1774
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)
Definition: integer.h:197
RCP< const Set > interval(const RCP< const Number > &start, const RCP< const Number > &end, const bool left_open=false, const bool right_open=false)
Definition: sets.h:611
T set_union(T... args)

Field Documentation

◆ domain_

RCP<const Set> SymEngine::InvertComplexVisitor::domain_
protected

Definition at line 364 of file solve.cpp.

◆ gY_

RCP<const Set> SymEngine::InvertComplexVisitor::gY_
protected

Definition at line 361 of file solve.cpp.

◆ nD_

RCP<const Dummy> SymEngine::InvertComplexVisitor::nD_
protected

Definition at line 362 of file solve.cpp.

◆ result_

RCP<const Set> SymEngine::InvertComplexVisitor::result_
protected

Definition at line 360 of file solve.cpp.

◆ sym_

RCP<const Symbol> SymEngine::InvertComplexVisitor::sym_
protected

Definition at line 363 of file solve.cpp.


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