3 * Interface to class for extended truncated power series.
5 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
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.
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.
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
22 #ifndef __GINAC_SERIES_H__
23 #define __GINAC_SERIES_H__
25 #include <ginac/basic.h>
26 #include <ginac/expairseq.h>
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
34 typedef basic inherited;
36 // default constructor, destructor, copy constructor, assignment operator and helpers
40 series(series const &other);
41 series const &operator=(series const &other);
43 void copy(series const &other);
44 void destroy(bool call_parent);
48 series(ex const &var_, ex const &point_, epvector const &ops_);
50 // functions overriding virtual functions from base classes
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;
63 // non-virtual functions in this class
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;
74 /** Vector of {coefficient, power} pairs */
77 /** Series variable (holds a symbol) */
80 /** Expansion point */
85 extern const series some_series;
86 extern type_info const & typeid_series;
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))
91 #endif // ndef __GINAC_SERIES_H__