]> www.ginac.de Git - ginac.git/blob - ginac/series.h
- switched to automake build environment
[ginac.git] / ginac / series.h
1 /** @file series.h
2  *
3  *  Interface to class for extended truncated power series. */
4
5 #ifndef _SERIES_H_
6 #define _SERIES_H_
7
8 #include "basic.h"
9 #include "ex.h"
10 #include "expairseq.h"
11 #include "symbol.h"
12
13
14 /** This class holds a extended truncated power series (positive and negative
15  *  integer powers). It consists of expression coefficients (only non-zero
16  *  coefficients are stored), an expansion variable and an expansion point.
17  *  Other classes must provide members to convert into this type. */
18 class series : public basic
19 {
20     typedef basic inherited;
21
22     // default constructor, destructor, copy constructor, assignment operator and helpers
23 public:
24     series();
25     ~series();
26     series(series const &other);
27     series const &operator=(series const &other);
28 protected:
29     void copy(series const &other);
30     void destroy(bool call_parent);
31
32     // other constructors
33 public:
34     series(ex const &var_, ex const &point_, epvector const &ops_);
35
36     // functions overriding virtual functions from base classes
37 public:
38     basic *duplicate() const;
39     void printraw(ostream &os) const;
40     void print(ostream &os, unsigned upper_precedence=0) const;
41     int degree(symbol const &s) const;
42     int ldegree(symbol const &s) const;
43     ex coeff(symbol const &s, int const n=1) const;
44     ex eval(int level=0) const;
45     ex evalf(int level=0) const;
46     ex diff(symbol const & s) const;
47     ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
48
49     // non-virtual functions in this class
50 public:
51     ex convert_to_poly(bool no_order = false) const;
52     bool is_compatible_to(const series &other) const {return var.compare(other.var) == 0 && point.compare(other.point) == 0;}
53     bool is_zero(void) const {return seq.size() == 0;}
54     ex add_series(const series &other) const;
55     ex mul_const(const numeric &other) const;
56     ex mul_series(const series &other) const;
57     ex power_const(const numeric &p, int deg) const;
58
59 protected:
60     /** Vector of {coefficient, power} pairs */
61     epvector seq;
62
63     /** Series variable (holds a symbol) */
64     ex var;
65
66     /** Expansion point */
67     ex point;
68 };
69
70 // global constants
71 extern const series some_series;
72 extern type_info const & typeid_series;
73
74 #define ex_to_series(X) (static_cast<class series const &>(*(X).bp))
75 #define series_to_poly(X) (static_cast<series const &>(*(X).bp).convert_to_poly(true))
76
77 #endif