]> www.ginac.de Git - ginac.git/blob - ginac/series.h
- corrected meaning of "GiNaC" acronym
[ginac.git] / ginac / series.h
1 /** @file series.h
2  *
3  *  Interface to class for extended truncated power series.
4  *
5  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #ifndef __GINAC_SERIES_H__
23 #define __GINAC_SERIES_H__
24
25 #include <ginac/basic.h>
26 #include <ginac/expairseq.h>
27
28 /** This class holds a extended truncated power series (positive and negative
29  *  integer powers). It consists of expression coefficients (only non-zero
30  *  coefficients are stored), an expansion variable and an expansion point.
31  *  Other classes must provide members to convert into this type. */
32 class series : public basic
33 {
34     typedef basic inherited;
35
36     // default constructor, destructor, copy constructor, assignment operator and helpers
37 public:
38     series();
39     ~series();
40     series(series const &other);
41     series const &operator=(series const &other);
42 protected:
43     void copy(series const &other);
44     void destroy(bool call_parent);
45
46     // other constructors
47 public:
48     series(ex const &var_, ex const &point_, epvector const &ops_);
49
50     // functions overriding virtual functions from base classes
51 public:
52     basic *duplicate() const;
53     void printraw(ostream &os) const;
54     void print(ostream &os, unsigned upper_precedence=0) const;
55     int degree(symbol const &s) const;
56     int ldegree(symbol const &s) const;
57     ex coeff(symbol const &s, int const n=1) const;
58     ex eval(int level=0) const;
59     ex evalf(int level=0) const;
60     ex diff(symbol const & s) const;
61     ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
62
63     // non-virtual functions in this class
64 public:
65     ex convert_to_poly(bool no_order = false) const;
66     bool is_compatible_to(const series &other) const {return var.compare(other.var) == 0 && point.compare(other.point) == 0;}
67     bool is_zero(void) const {return seq.size() == 0;}
68     ex add_series(const series &other) const;
69     ex mul_const(const numeric &other) const;
70     ex mul_series(const series &other) const;
71     ex power_const(const numeric &p, int deg) const;
72
73 protected:
74     /** Vector of {coefficient, power} pairs */
75     epvector seq;
76
77     /** Series variable (holds a symbol) */
78     ex var;
79
80     /** Expansion point */
81     ex point;
82 };
83
84 // global constants
85 extern const series some_series;
86 extern type_info const & typeid_series;
87
88 #define ex_to_series(X) (static_cast<class series const &>(*(X).bp))
89 #define series_to_poly(X) (static_cast<series const &>(*(X).bp).convert_to_poly(true))
90
91 #endif // ndef __GINAC_SERIES_H__