1 #include <symengine/series_visitor.h>
3 #ifdef HAVE_SYMENGINE_FLINT
7 URatPSeriesFlint::URatPSeriesFlint(fqp_t p,
const std::string varname,
9 : SeriesBase(
std::
move(p), varname, degree){SYMENGINE_ASSIGN_TYPEID()} RCP<
10 const URatPSeriesFlint> URatPSeriesFlint::series(
const RCP<const Basic>
16 SeriesVisitor<fqp_t, fmpq_wrapper, URatPSeriesFlint> visitor(p, x, prec);
17 return visitor.series(t);
20 hash_t URatPSeriesFlint::__hash__()
const
23 hash_t seed = SYMENGINE_URATPSERIESFLINT;
30 RCP<const Basic> URatPSeriesFlint::as_basic()
const
32 RCP<const Symbol> x =
symbol(var_);
33 RCP<const Number> zcoef;
37 for (
unsigned n = 0; n < degree_; n++) {
38 const fmpq_wrapper fc(p_.get_coeff(n));
39 if (not fc.is_zero()) {
40 fmpq_get_mpq(gc, fc.get_fmpq_t());
41 RCP<const Number> basic = Rational::from_mpq(rational_class(gc));
46 Add::coef_dict_add_term(outArg(basic), dict_, one, term);
51 return Add::from_dict(zcoef,
std::move(dict_));
54 umap_int_basic URatPSeriesFlint::as_dict()
const
59 for (
unsigned n = 0; n < degree_; n++) {
60 const fmpq_wrapper fc(p_.get_coeff(n));
61 if (not fc.is_zero()) {
62 fmpq_get_mpq(gc, fc.get_fmpq_t());
63 RCP<const Number> basic = Rational::from_mpq(rational_class(gc));
71 RCP<const Basic> URatPSeriesFlint::get_coeff(
int n)
const
73 const fmpq_wrapper fc(p_.get_coeff(n));
76 fmpq_get_mpq(gc, fc.get_fmpq_t());
82 int URatPSeriesFlint::compare(
const Basic &o)
const
84 SYMENGINE_ASSERT(is_a<URatPSeriesFlint>(o))
85 const URatPSeriesFlint &s = down_cast<const URatPSeriesFlint &>(o);
87 return (var_ < s.var_) ? -1 : 1;
88 if (degree_ != s.degree_)
89 return (degree_ < s.degree_) ? -1 : 1;
92 return (p_ < s.p_) ? -1 : 1;
101 fqp_t URatPSeriesFlint::convert(
const integer_class &x)
103 return fqp_t(get_mpz_t(x));
106 fqp_t URatPSeriesFlint::convert(
const rational_class &x)
108 return fqp_t(get_mpq_t(x));
111 fqp_t URatPSeriesFlint::convert(
const Integer &x)
113 return convert(x.as_integer_class());
116 fqp_t URatPSeriesFlint::convert(
const Rational &x)
118 return convert(x.as_rational_class());
121 fqp_t URatPSeriesFlint::convert(
const Basic &x)
123 throw NotImplementedError(
"SeriesFlint::convert not Implemented");
126 fqp_t URatPSeriesFlint::pow(
const fqp_t &s,
int n,
unsigned prec)
129 return fqp_t(s.pow(
unsigned(n)));
131 return fqp_t(s.inv_series(prec).pow(
unsigned(-n)));
135 unsigned URatPSeriesFlint::ldegree(
const fqp_t &s)
138 while (i <= numeric_cast<int>(s.degree()))
139 if (not s.get_coeff(i++).is_zero())
140 return numeric_cast<unsigned>(i - 1);
144 fmpq_wrapper URatPSeriesFlint::root(fmpq_wrapper &c,
unsigned n)
146 fmpq_wrapper cl_rat = c, cl_root;
147 cl_rat.canonicalise();
148 cl_root.get_num() = cl_rat.get_num().root(n);
149 if (cl_rat.get_den() == 1)
150 cl_root.get_den() = 1;
152 cl_root.get_den() = cl_rat.get_den().root(n);
156 fqp_t URatPSeriesFlint::diff(
const fqp_t &s,
const fqp_t &var)
158 return s.derivative();
161 fqp_t URatPSeriesFlint::integrate(
const fqp_t &s,
const fqp_t &var)
166 fqp_t URatPSeriesFlint::subs(
const fqp_t &s,
const fqp_t &var,
const fqp_t &r,
169 return s.subs(r, prec);
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
void hash_combine(hash_t &seed, const T &v)
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.