]> www.ginac.de Git - ginac.git/blob - ginac/series.h
- enforced GiNaC coding standards :-)
[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 /** This class holds a extended truncated power series (positive and negative
26  *  integer powers). It consists of expression coefficients (only non-zero
27  *  coefficients are stored), an expansion variable and an expansion point.
28  *  Other classes must provide members to convert into this type. */
29 class series : public basic
30 {
31     typedef basic inherited;
32
33     // default constructor, destructor, copy constructor, assignment operator and helpers
34 public:
35     series();
36     ~series();
37     series(series const &other);
38     series const &operator=(series const &other);
39 protected:
40     void copy(series const &other);
41     void destroy(bool call_parent);
42
43     // other constructors
44 public:
45     series(ex const &var_, ex const &point_, epvector const &ops_);
46
47     // functions overriding virtual functions from base classes
48 public:
49     basic *duplicate() const;
50     void printraw(ostream &os) const;
51     void print(ostream &os, unsigned upper_precedence=0) const;
52     int degree(symbol const &s) const;
53     int ldegree(symbol const &s) const;
54     ex coeff(symbol const &s, int const n=1) const;
55     ex eval(int level=0) const;
56     ex evalf(int level=0) const;
57     ex diff(symbol const & s) const;
58     ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
59
60     // non-virtual functions in this class
61 public:
62     ex convert_to_poly(bool no_order = false) const;
63     bool is_compatible_to(const series &other) const {return var.compare(other.var) == 0 && point.compare(other.point) == 0;}
64     bool is_zero(void) const {return seq.size() == 0;}
65     ex add_series(const series &other) const;
66     ex mul_const(const numeric &other) const;
67     ex mul_series(const series &other) const;
68     ex power_const(const numeric &p, int deg) const;
69
70 protected:
71     /** Vector of {coefficient, power} pairs */
72     epvector seq;
73
74     /** Series variable (holds a symbol) */
75     ex var;
76
77     /** Expansion point */
78     ex point;
79 };
80
81 // global constants
82 extern const series some_series;
83 extern type_info const & typeid_series;
84
85 #define ex_to_series(X) (static_cast<class series const &>(*(X).bp))
86 #define series_to_poly(X) (static_cast<series const &>(*(X).bp).convert_to_poly(true))
87
88 #endif // ndef __GINAC_SERIES_H__