4 #include <symengine/series.h>
5 #include <symengine/expression.h>
8 #include <piranha/monomial.hpp>
9 #include <piranha/polynomial.hpp>
11 namespace SymEngine
12 {
14 using pp_t = piranha::polynomial<piranha::rational, piranha::monomial<short>>;
15 // Univariate Rational Coefficient Power SeriesBase using Piranha
16 class URatPSeriesPiranha
17  : public SeriesBase<pp_t, piranha::rational, URatPSeriesPiranha>
18 {
19 public:
20  URatPSeriesPiranha(const pp_t p, const std::string varname,
21  const unsigned degree);
23  virtual int compare(const Basic &o) const;
24  virtual hash_t __hash__() const;
25  virtual RCP<const Basic> as_basic() const;
26  virtual umap_int_basic as_dict() const;
27  virtual RCP<const Basic> get_coeff(int) const;
29  static RCP<const URatPSeriesPiranha>
30  series(const RCP<const Basic> &t, const std::string &x, unsigned int prec);
31  static piranha::integer convert(const Integer &x);
32  static piranha::rational convert(const rational_class &x);
33  static pp_t var(const std::string &s);
34  static piranha::rational convert(const Rational &x);
35  static piranha::rational convert(const Basic &x);
36  static pp_t mul(const pp_t &s, const pp_t &r, unsigned prec);
37  static pp_t pow(const pp_t &s, int n, unsigned prec);
38  static unsigned ldegree(const pp_t &s);
39  static piranha::rational find_cf(const pp_t &s, const pp_t &var,
40  unsigned deg);
41  static piranha::rational root(piranha::rational &c, unsigned n);
42  static pp_t diff(const pp_t &s, const pp_t &var);
43  static pp_t integrate(const pp_t &s, const pp_t &var);
44  static pp_t subs(const pp_t &s, const pp_t &var, const pp_t &r,
45  unsigned prec);
46 };
48 using p_expr = piranha::polynomial<Expression, piranha::monomial<int>>;
49 // Univariate Rational Coefficient Power SeriesBase using Piranha
50 class UPSeriesPiranha : public SeriesBase<p_expr, Expression, UPSeriesPiranha>
51 {
52 public:
53  UPSeriesPiranha(const p_expr p, const std::string varname,
54  const unsigned degree);
56  virtual int compare(const Basic &o) const;
57  virtual hash_t __hash__() const;
58  virtual RCP<const Basic> as_basic() const;
59  virtual umap_int_basic as_dict() const;
60  virtual RCP<const Basic> get_coeff(int) const;
62  static RCP<const UPSeriesPiranha>
63  series(const RCP<const Basic> &t, const std::string &x, unsigned int prec);
64  static p_expr var(const std::string &s);
65  static Expression convert(const Basic &x);
66  static p_expr mul(const p_expr &s, const p_expr &r, unsigned prec);
67  static p_expr pow(const p_expr &s, int n, unsigned prec);
68  static unsigned ldegree(const p_expr &s);
69  static Expression find_cf(const p_expr &s, const p_expr &var, unsigned deg);
70  static Expression root(Expression &c, unsigned n);
71  static p_expr diff(const p_expr &s, const p_expr &var);
72  static p_expr integrate(const p_expr &s, const p_expr &var);
73  static p_expr subs(const p_expr &s, const p_expr &var, const p_expr &r,
74  unsigned prec);
76  static Expression sin(const Expression &c);
77  static Expression cos(const Expression &c);
78  static Expression tan(const Expression &c);
79  static Expression asin(const Expression &c);
80  static Expression acos(const Expression &c);
81  static Expression atan(const Expression &c);
82  static Expression sinh(const Expression &c);
83  static Expression cosh(const Expression &c);
84  static Expression tanh(const Expression &c);
85  static Expression asinh(const Expression &c);
86  static Expression atanh(const Expression &c);
87  static Expression exp(const Expression &c);
88  static Expression log(const Expression &c);
89 };
90 } // namespace SymEngine
Inline members and functions.
Definition: basic.h:340
Main namespace for SymEngine package.
Definition: add.cpp:19
RCP< const Basic > acos(const RCP< const Basic > &arg)
Canonicalize ACos:
Definition: functions.cpp:1402
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
Definition: integer.h:197
RCP< const Basic > exp(const RCP< const Basic > &x)
Returns the natural exponential function E**x = pow(E, x)
Definition: pow.cpp:271
RCP< const Basic > asin(const RCP< const Basic > &arg)
Canonicalize ASin:
Definition: functions.cpp:1360
RCP< const Basic > tan(const RCP< const Basic > &arg)
Canonicalize Tan:
Definition: functions.cpp:1007
RCP< const Basic > cosh(const RCP< const Basic > &arg)
Canonicalize Cosh:
Definition: functions.cpp:2212
RCP< const Basic > atan(const RCP< const Basic > &arg)
Canonicalize ATan:
Definition: functions.cpp:1524
RCP< const Basic > asinh(const RCP< const Basic > &arg)
Canonicalize ASinh:
Definition: functions.cpp:2376
RCP< const Basic > tanh(const RCP< const Basic > &arg)
Canonicalize Tanh:
Definition: functions.cpp:2290
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Definition: mul.cpp:352
RCP< const Basic > atanh(const RCP< const Basic > &arg)
Canonicalize ATanh:
Definition: functions.cpp:2494
RCP< const Basic > cos(const RCP< const Basic > &arg)
Canonicalize Cos:
Definition: functions.cpp:942
RCP< const Basic > log(const RCP< const Basic > &arg)
Returns the Natural Logarithm from argument arg
Definition: functions.cpp:1774
RCP< const Number > rational(long n, long d)
convenience creator from two longs
Definition: rational.h:328
RCP< const Basic > sinh(const RCP< const Basic > &arg)
Canonicalize Sinh:
Definition: functions.cpp:2127
RCP< const Basic > sin(const RCP< const Basic > &arg)
Canonicalize Sin:
Definition: functions.cpp:874
T pow(T... args)