5 #include <symengine/symengine_exception.h>
17 for (
const auto &p : d) {
18 if (not is_a<Integer>(*p.second))
19 throw NotImplementedError(
"Not Implemented");
20 coef = down_cast<const Integer &>(*p.second).as_integer_class();
22 if (is_a<Mul>(*p.first)) {
24 = down_cast<const Mul &>(*p.first).get_dict();
25 for (
const auto &q : term) {
26 RCP<const Basic> sym = q.first;
27 if (not is_a<Integer>(*syms.
at(sym)))
28 throw NotImplementedError(
"Not Implemented");
29 int i = numeric_cast<int>(
30 down_cast<const Integer &>(*syms.
at(sym)).as_int());
31 if (is_a<Integer>(*q.second)) {
32 exp[i] = numeric_cast<int>(
33 down_cast<const Integer &>(*q.second).as_int());
35 throw SymEngineException(
36 "Cannot convert symbolic exponents to sparse "
37 "polynomials with integer exponents.");
40 }
else if (is_a<Pow>(*p.first)) {
42 = down_cast<const Pow &>(*p.first).get_base();
44 = down_cast<const Pow &>(*p.first).get_exp();
45 if (not is_a<Integer>(*syms.
at(sym)))
46 throw NotImplementedError(
"Not Implemented");
47 int i = numeric_cast<int>(
48 down_cast<const Integer &>(*syms.
at(sym)).as_int());
49 if (not is_a<Integer>(*exp_))
50 throw NotImplementedError(
"Not Implemented");
51 exp[i] = numeric_cast<int>(
52 down_cast<const Integer &>(*exp_).as_int());
53 }
else if (is_a<Symbol>(*p.first)) {
54 RCP<const Basic> sym = p.first;
55 if (not is_a<Integer>(*syms.
at(sym)))
56 throw NotImplementedError(
"Not Implemented");
57 int i = numeric_cast<int>(
58 down_cast<const Integer &>(*syms.
at(sym)).as_int());
61 throw NotImplementedError(
"Not Implemented");
67 throw NotImplementedError(
"Not Implemented");
74 auto n = A.
begin()->first.size();
87 for (
const auto &a : A) {
88 for (
const auto &b : B) {
90 mp_addmul(C[
exp], a.second, b.second);
Classes and functions relating to the binary operation of addition.
Main namespace for SymEngine package.
void monomial_mul(const vec_int &A, const vec_int &B, vec_int &C)
Monomial multiplication.
RCP< const Basic > exp(const RCP< const Basic > &x)
Returns the natural exponential function E**x = pow(E, x)
void expr2poly(const RCP< const Basic > &p, umap_basic_num &syms, umap_vec_mpz &P)
Converts expression p into a polynomial P, with symbols sym
void poly_mul(const umap_vec_mpz &A, const umap_vec_mpz &B, umap_vec_mpz &C)
Multiply two polynomials: C = A*B