5 #ifndef SYMENGINE_UINTPOLY_H
6 #define SYMENGINE_UINTPOLY_H
8 #include <symengine/polys/usymenginepoly.h>
14 unsigned int bit_length(T t)
16 unsigned int count = 0;
42 integer_class
eval_bit(
const unsigned int &x)
const
44 unsigned int last_deg = dict_.rbegin()->first;
45 integer_class result(0);
47 for (
auto it = dict_.rbegin(); it != dict_.rend(); ++it) {
48 result <<= x * (last_deg - (*it).first);
49 result += (*it).second;
50 last_deg = (*it).first;
52 result <<= x * last_deg;
61 unsigned int N = bit_length(
std::min(a.degree() + 1, b.degree() + 1))
62 + bit_length(a.max_abs_coef())
63 + bit_length(b.max_abs_coef());
65 integer_class full = integer_class(1), temp, res;
67 integer_class thresh = full / 2;
68 integer_class mask = full - 1;
72 s_val = mp_abs(s_val);
74 unsigned int deg = 0, carry = 0;
77 while (s_val != 0 or carry != 0) {
78 mp_and(temp, s_val, mask);
80 res =
mul * (temp + carry);
85 res = mul * (temp - full + carry);
96 int compare(
const UIntDict &other)
const
98 if (dict_.size() != other.dict_.size())
99 return (dict_.size() < other.dict_.size()) ? -1 : 1;
103 integer_class max_abs_coef()
const
105 integer_class curr(mp_abs(dict_.begin()->second));
106 for (
const auto &it : dict_) {
107 if (mp_abs(it.second) > curr)
108 curr = mp_abs(it.second);
128 const Ptr<RCP<const UIntPoly>> &res);
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
integer_class eval_bit(const unsigned int &x) const
Evaluates the dict_ at value 2**x.
UIntPoly(const RCP< const Basic > &var, UIntDict &&dict)
Constructor of UIntPoly class.
hash_t __hash__() const override
Main namespace for SymEngine package.
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
int unified_compare(const T &a, const T &b)