5 #ifndef SYMENGINE_UEXPRPOLY_H
6 #define SYMENGINE_UEXPRPOLY_H
10 #include <symengine/polys/usymenginepoly.h>
55 for (
auto it = dict_.rbegin(); it != dict_.rend(); ++it) {
62 t = detail::poly_print(it->second);
73 if (it->second == 1 or it->second == -1) {
80 if (down_cast<const Integer &>(*it->second.get_basic())
94 else if (it->second == 0)
101 o << detail::poly_print(it->second) <<
"*";
103 t = detail::poly_print(it->second);
105 o <<
" - " << t.
substr(1);
115 o <<
"**" << it->first;
116 }
else if (it->first < 0) {
117 o <<
"**(" << it->first <<
")";
127 const RCP<const Basic> get_basic(
std::string var)
const
129 RCP<const Symbol> x =
symbol(var);
131 RCP<const Number> coeff = zero;
132 for (
const auto &it : dict_) {
136 SymEngine::pow(x,
integer(it.first)));
140 it.second.get_basic());
146 int compare(
const UExprDict &other)
const
153 if (dict_.find(deg) != dict_.end())
154 return dict_.at(deg);
192 inline RCP<const UExprPoly> uexpr_poly(RCP<const Basic> i,
UExprDict &&dict)
194 return UExprPoly::from_container(i,
std::move(dict));
197 inline RCP<const UExprPoly> uexpr_poly(RCP<const Basic> i, map_int_Expr &&dict)
199 return UExprPoly::from_dict(i,
std::move(dict));
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
static RCP< const Basic > from_dict(const RCP< const Number > &coef, umap_basic_num &&d)
Create an appropriate instance from dictionary quickly.
static void coef_dict_add_term(const Ptr< RCP< const Number >> &coef, umap_basic_num &d, const RCP< const Number > &c, const RCP< const Basic > &term)
Updates the numerical coefficient and the dictionary.
hash_t __hash__() const override
bool is_minus_one() const
UExprPoly(const RCP< const Basic > &var, UExprDict &&dict)
Constructor of UExprPoly class.
Expression eval(const Expression &x) const
Evaluates the UExprPoly at value x.
Main namespace for SymEngine package.
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
RCP< const Symbol > symbol(const std::string &name)
inline version to return Symbol
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
int unified_compare(const T &a, const T &b)