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