3 * Interface to class for extended truncated power series. */
6 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
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.
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.
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
23 #ifndef __GINAC_SERIES_H__
24 #define __GINAC_SERIES_H__
26 #include <ginac/basic.h>
27 #include <ginac/expairseq.h>
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
35 typedef basic inherited;
37 // default constructor, destructor, copy constructor, assignment operator and helpers
41 series(series const &other);
42 series const &operator=(series const &other);
44 void copy(series const &other);
45 void destroy(bool call_parent);
49 series(ex const &var_, ex const &point_, epvector const &ops_);
51 // functions overriding virtual functions from base classes
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;
64 // non-virtual functions in this class
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;
75 /** Vector of {coefficient, power} pairs */
78 /** Series variable (holds a symbol) */
81 /** Expansion point */
86 extern const series some_series;
87 extern type_info const & typeid_series;
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))
92 #endif // ndef __GINAC_SERIES_H__