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

Public Member Functions

 RationalVisitor (bool rational)
 
void bvisit (const Basic &x)
 
void bvisit (const Symbol &x)
 
void bvisit (const Integer &x)
 
void bvisit (const Rational &x)
 
void bvisit (const Number &x)
 
void bvisit (const Set &x)
 
void bvisit (const Relational &x)
 
void bvisit (const Boolean &x)
 
void bvisit (const Constant &x)
 
void bvisit (const Add &x)
 
tribool apply (const Basic &b)
 

Private Attributes

bool rational_
 
tribool is_rational_
 
bool neither_ = false
 

Detailed Description

Definition at line 362 of file test_visitors.h.

Constructor & Destructor Documentation

◆ RationalVisitor()

SymEngine::RationalVisitor::RationalVisitor ( bool  rational)
inline

Definition at line 370 of file test_visitors.h.

370: rational_{rational} {}
RCP< const Number > rational(long n, long d)
convenience creator from two longs
Definition: rational.h:328

Member Function Documentation

◆ apply()

tribool SymEngine::RationalVisitor::apply ( const Basic b)

Definition at line 848 of file test_visitors.cpp.

849{
850 b.accept(*this);
851 tribool result = is_rational_;
852 if (not rational_ and not neither_) {
853 result = not_tribool(result);
854 }
855 return result;
856}

◆ bvisit() [1/10]

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

Definition at line 837 of file test_visitors.cpp.

838{
839 tribool b = tribool::tritrue;
840 for (const auto &arg : x.get_args()) {
841 arg->accept(*this);
842 b = andwk_tribool(b, is_rational_);
843 if (is_indeterminate(b))
844 return;
845 }
846}

◆ bvisit() [2/10]

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

Definition at line 371 of file test_visitors.h.

372 {
373 is_rational_ = tribool::indeterminate;
374 };

◆ bvisit() [3/10]

void SymEngine::RationalVisitor::bvisit ( const Boolean x)
inline

Definition at line 398 of file test_visitors.h.

399 {
400 is_rational_ = tribool::trifalse;
401 neither_ = true;
402 };

◆ bvisit() [4/10]

void SymEngine::RationalVisitor::bvisit ( const Constant x)

Definition at line 826 of file test_visitors.cpp.

827{
828 if (eq(x, *pi) or eq(x, *E) or eq(x, *GoldenRatio)) {
829 // It is currently (2021) not known whether Catalan's constant
830 // or Euler's constant are rational or irrational
831 is_rational_ = tribool::trifalse;
832 } else {
833 is_rational_ = tribool::indeterminate;
834 }
835}
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21

◆ bvisit() [5/10]

void SymEngine::RationalVisitor::bvisit ( const Integer x)
inline

Definition at line 379 of file test_visitors.h.

380 {
381 is_rational_ = tribool::tritrue;
382 };

◆ bvisit() [6/10]

void SymEngine::RationalVisitor::bvisit ( const Number x)

Definition at line 818 of file test_visitors.cpp.

819{
820 is_rational_ = tribool::trifalse;
821 if (is_a_Complex(x) or is_a<Infty>(x) or is_a<NaN>(x)) {
822 neither_ = true;
823 }
824}
bool is_a_Complex(const Basic &b)
Definition: complex.h:24

◆ bvisit() [7/10]

void SymEngine::RationalVisitor::bvisit ( const Rational x)
inline

Definition at line 383 of file test_visitors.h.

384 {
385 is_rational_ = tribool::tritrue;
386 };

◆ bvisit() [8/10]

void SymEngine::RationalVisitor::bvisit ( const Relational x)
inline

Definition at line 393 of file test_visitors.h.

394 {
395 is_rational_ = tribool::trifalse;
396 neither_ = true;
397 };

◆ bvisit() [9/10]

void SymEngine::RationalVisitor::bvisit ( const Set x)
inline

Definition at line 388 of file test_visitors.h.

389 {
390 is_rational_ = tribool::trifalse;
391 neither_ = true;
392 };

◆ bvisit() [10/10]

void SymEngine::RationalVisitor::bvisit ( const Symbol x)
inline

Definition at line 375 of file test_visitors.h.

376 {
377 is_rational_ = tribool::indeterminate;
378 };

Field Documentation

◆ is_rational_

tribool SymEngine::RationalVisitor::is_rational_
private

Definition at line 366 of file test_visitors.h.

◆ neither_

bool SymEngine::RationalVisitor::neither_ = false
private

Definition at line 367 of file test_visitors.h.

◆ rational_

bool SymEngine::RationalVisitor::rational_
private

Definition at line 365 of file test_visitors.h.


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