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

Public Member Functions

umap_basic_num apply (const Basic &b)
 
void add_to_gen_set (const RCP< const Basic > &base, const RCP< const Number > &exp)
 
void bvisit (const Pow &x)
 
void bvisit (const Add &x)
 
void bvisit (const Mul &x)
 
void bvisit (const Number &x)
 
void bvisit (const Basic &x)
 

Private Attributes

umap_basic_num gen_set
 

Detailed Description

Definition at line 10 of file basic_conversions.cpp.

Member Function Documentation

◆ add_to_gen_set()

void SymEngine::PolyGeneratorVisitor::add_to_gen_set ( const RCP< const Basic > &  base,
const RCP< const Number > &  exp 
)
inline

Definition at line 26 of file basic_conversions.cpp.

28 {
29 auto it = gen_set.find(base);
30 if (it == gen_set.end()) {
31 gen_set[base] = exp;
32 return;
33 }
34
35 if (is_a<const Rational>(*exp)) {
36 RCP<const Integer> den
37 = down_cast<const Rational &>(*exp).get_den();
38 if (is_a<const Rational>(*it->second))
39 gen_set[base] = divnum(
40 one,
41 lcm(*den,
42 *down_cast<const Rational &>(*it->second).get_den()));
43 else
44 gen_set[base] = divnum(one, den);
45 }
46 }
T end(T... args)
T find(T... args)
RCP< const Basic > exp(const RCP< const Basic > &x)
Returns the natural exponential function E**x = pow(E, x)
Definition: pow.cpp:271
RCP< const Integer > lcm(const Integer &a, const Integer &b)
Least Common Multiple.
Definition: ntheory.cpp:49
RCP< const Number > divnum(const RCP< const Number > &self, const RCP< const Number > &other)
Divide self and other
Definition: number.h:99

◆ apply()

umap_basic_num SymEngine::PolyGeneratorVisitor::apply ( const Basic b)
inline

Definition at line 19 of file basic_conversions.cpp.

20 {
21 b.accept(*this);
22 return std::move(gen_set);
23 }
T move(T... args)

◆ bvisit() [1/5]

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

Definition at line 74 of file basic_conversions.cpp.

75 {
76 for (auto it : x.get_dict())
77 it.first->accept(*this);
78 }

◆ bvisit() [2/5]

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

Definition at line 91 of file basic_conversions.cpp.

92 {
93 add_to_gen_set(x.rcp_from_this(), one);
94 }

◆ bvisit() [3/5]

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

Definition at line 80 of file basic_conversions.cpp.

81 {
82 for (auto it : x.get_dict())
83 it.first->accept(*this);
84 }

◆ bvisit() [4/5]

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

Definition at line 86 of file basic_conversions.cpp.

87 {
88 // intentionally blank
89 }

◆ bvisit() [5/5]

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

Definition at line 48 of file basic_conversions.cpp.

49 {
50 if (is_a<const Integer>(*x.get_exp())) {
51 if (down_cast<const Integer &>(*x.get_exp()).is_positive()) {
52 x.get_base()->accept(*this);
53 } else {
54 add_to_gen_set(pow(x.get_base(), minus_one), one);
55 }
56
57 } else if (is_a<const Rational>(*x.get_exp())) {
58
59 RCP<const Basic> base = x.get_base();
60 RCP<const Rational> r
61 = rcp_static_cast<const Rational>(x.get_exp());
62 if (r->is_negative())
63 base = pow(base, minus_one);
64 add_to_gen_set(base, divnum(one, r->get_den()));
65
66 } else {
67 umap_basic_num pow_pairs
68 = _find_gens_poly_pow(x.get_exp(), x.get_base());
69 for (auto it : pow_pairs)
70 add_to_gen_set(pow(x.get_base(), it.first), it.second);
71 }
72 }
T pow(T... args)

Field Documentation

◆ gen_set

umap_basic_num SymEngine::PolyGeneratorVisitor::gen_set
private

Definition at line 16 of file basic_conversions.cpp.


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