1 #ifndef SYMENGINE_USYMENGINEPOLY_H
2 #define SYMENGINE_USYMENGINEPOLY_H
4 #include <symengine/polys/upolybase.h>
9 template <
typename Container,
template <
typename X,
typename Y>
class BaseType,
14 using Cf =
typename BaseType<Container, Poly>::coef_type;
15 using Key =
typename Container::key_type;
18 : BaseType<Container, Poly>(var,
std::move(dict))
22 int compare(
const Basic &o)
const
24 SYMENGINE_ASSERT(is_a<Poly>(o))
25 const Poly &s = down_cast<const Poly &>(o);
27 if (this->get_poly().size() != s.get_poly().size())
28 return (this->get_poly().size() < s.get_poly().size()) ? -1 : 1;
37 bool is_canonical(
const Container &dict)
const
40 for (
auto iter : dict.dict_)
46 static RCP<const Poly> from_vec(
const RCP<const Basic> &var,
49 return make_rcp<const Poly>(var, Container::from_vec(v));
52 static Container container_from_dict(
const RCP<const Basic> &var,
58 template <
typename FromPoly>
59 static enable_if_t<is_a_UPoly<FromPoly>::value, RCP<const Poly>>
60 from_poly(
const FromPoly &p)
62 return Poly::from_container(p.get_var(),
66 Cf eval(
const Cf &x)
const
68 Key last_deg = this->get_poly().dict_.rbegin()->first;
71 for (
auto it = this->get_poly().dict_.rbegin();
72 it != this->get_poly().dict_.rend(); ++it) {
73 mp_pow_ui(x_pow, x, last_deg - (*it).first);
74 last_deg = (*it).first;
75 result = (*it).second + x_pow * result;
77 mp_pow_ui(x_pow, x, last_deg);
85 return this->get_poly().dict_;
88 inline Cf get_coeff(Key x)
const
90 return this->get_poly().get_coeff(x);
95 iterator begin()
const
97 return this->get_poly().dict_.
begin();
101 return this->get_poly().dict_.end();
103 r_iterator obegin()
const
105 return this->get_poly().dict_.rbegin();
107 r_iterator oend()
const
109 return this->get_poly().dict_.rend();
114 if (this->get_poly().dict_.empty())
116 return this->get_degree() + 1;
120 template <
typename Container,
template <
typename X,
typename Y>
class BaseType,
125 auto dict = Poly::container_type::pow(a.get_poly(), p);
126 return Poly::from_container(a.get_var(),
std::move(dict));
The lowest unit of symbolic representation.
Main namespace for SymEngine package.
int unified_compare(const T &a, const T &b)