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

Public Member Functions

 ZeroVisitor (const Assumptions *assumptions)
 
void bvisit (const Basic &x)
 
void bvisit (const Symbol &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 Abs &x)
 
void bvisit (const Conjugate &x)
 
void bvisit (const Sign &x)
 
void bvisit (const PrimePi &x)
 
tribool apply (const Basic &b)
 

Private Member Functions

void error ()
 

Private Attributes

tribool is_zero_
 
const Assumptionsassumptions_
 

Detailed Description

Definition at line 9 of file test_visitors.h.

Constructor & Destructor Documentation

◆ ZeroVisitor()

SymEngine::ZeroVisitor::ZeroVisitor ( const Assumptions assumptions)
inline

Definition at line 18 of file test_visitors.h.

18: assumptions_(assumptions) {}

Member Function Documentation

◆ apply()

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

Definition at line 76 of file test_visitors.cpp.

77{
78 b.accept(*this);
79 return is_zero_;
80}

◆ bvisit() [1/11]

void SymEngine::ZeroVisitor::bvisit ( const Abs x)

Definition at line 37 of file test_visitors.cpp.

38{
39 x.get_arg()->accept(*this);
40}

◆ bvisit() [2/11]

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

Definition at line 12 of file test_visitors.cpp.

13{
14 is_zero_ = tribool::indeterminate;
15}

◆ bvisit() [3/11]

void SymEngine::ZeroVisitor::bvisit ( const Boolean x)

Definition at line 27 of file test_visitors.cpp.

28{
29 error();
30}

◆ bvisit() [4/11]

void SymEngine::ZeroVisitor::bvisit ( const Conjugate x)

Definition at line 42 of file test_visitors.cpp.

43{
44 x.get_arg()->accept(*this);
45}

◆ bvisit() [5/11]

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

Definition at line 32 of file test_visitors.cpp.

33{
34 is_zero_ = tribool::trifalse;
35}

◆ bvisit() [6/11]

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

Definition at line 58 of file test_visitors.cpp.

59{
60 if (bool(x.is_zero())) {
61 is_zero_ = tribool::tritrue;
62 } else {
63 is_zero_ = tribool::trifalse;
64 }
65}

◆ bvisit() [7/11]

void SymEngine::ZeroVisitor::bvisit ( const PrimePi x)

Definition at line 52 of file test_visitors.cpp.

53{
54 // First prime is 2 so pi(x) is zero for x < 2
55 is_zero_ = is_negative(*sub(x.get_arg(), integer(2)));
56}
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
Definition: add.cpp:495
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)
Definition: integer.h:200

◆ bvisit() [8/11]

void SymEngine::ZeroVisitor::bvisit ( const Relational x)

Definition at line 22 of file test_visitors.cpp.

23{
24 error();
25}

◆ bvisit() [9/11]

void SymEngine::ZeroVisitor::bvisit ( const Set x)

Definition at line 17 of file test_visitors.cpp.

18{
19 error();
20}

◆ bvisit() [10/11]

void SymEngine::ZeroVisitor::bvisit ( const Sign x)

Definition at line 47 of file test_visitors.cpp.

48{
49 x.get_arg()->accept(*this);
50}

◆ bvisit() [11/11]

void SymEngine::ZeroVisitor::bvisit ( const Symbol x)

Definition at line 67 of file test_visitors.cpp.

68{
69 if (assumptions_) {
70 is_zero_ = assumptions_->is_zero(x.rcp_from_this());
71 } else {
72 is_zero_ = tribool::indeterminate;
73 }
74}

◆ error()

void SymEngine::ZeroVisitor::error ( )
private

Definition at line 6 of file test_visitors.cpp.

7{
8 throw SymEngineException(
9 "Only numeric types allowed for is_zero/is_nonzero");
10}

Field Documentation

◆ assumptions_

const Assumptions* SymEngine::ZeroVisitor::assumptions_
private

Definition at line 13 of file test_visitors.h.

◆ is_zero_

tribool SymEngine::ZeroVisitor::is_zero_
private

Definition at line 12 of file test_visitors.h.


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