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>
31 /** This class holds a extended truncated power series (positive and negative
32 * integer powers). It consists of expression coefficients (only non-zero
33 * coefficients are stored), an expansion variable and an expansion point.
34 * Other classes must provide members to convert into this type. */
35 class series : public basic
37 typedef basic inherited;
39 // default constructor, destructor, copy constructor, assignment operator and helpers
43 series(series const &other);
44 series const &operator=(series const &other);
46 void copy(series const &other);
47 void destroy(bool call_parent);
51 series(ex const &var_, ex const &point_, epvector const &ops_);
53 // functions overriding virtual functions from base classes
55 basic *duplicate() const;
56 void printraw(ostream &os) const;
57 void print(ostream &os, unsigned upper_precedence=0) const;
58 int degree(symbol const &s) const;
59 int ldegree(symbol const &s) const;
60 ex coeff(symbol const &s, int const n=1) const;
61 ex eval(int level=0) const;
62 ex evalf(int level=0) const;
63 ex diff(symbol const & s) const;
64 ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
66 // non-virtual functions in this class
68 ex convert_to_poly(bool no_order = false) const;
69 bool is_compatible_to(const series &other) const {return var.compare(other.var) == 0 && point.compare(other.point) == 0;}
70 bool is_zero(void) const {return seq.size() == 0;}
71 ex add_series(const series &other) const;
72 ex mul_const(const numeric &other) const;
73 ex mul_series(const series &other) const;
74 ex power_const(const numeric &p, int deg) const;
77 /** Vector of {coefficient, power} pairs */
80 /** Series variable (holds a symbol) */
83 /** Expansion point */
88 extern const series some_series;
89 extern type_info const & typeid_series;
91 /** Return a reference to the series object embedded in an expression.
92 * The result is undefined if the expression does not contain a series
93 * object at its top level.
96 * @return reference to series object
97 * @see is_ex_of_type */
98 inline const series &ex_to_series(const ex &e)
100 return static_cast<const series &>(*e.bp);
103 /** Convert the series object embedded in an expression to an ordinary
104 * polynomial in the expansion variable. The result is undefined if the
105 * expression does not contain a series object at its top level.
107 * @param e expression
108 * @return polynomial expression
110 * @see series::convert_to_poly */
111 inline ex series_to_poly(const ex &e)
113 return (static_cast<const series &>(*e.bp).convert_to_poly(true));
118 #endif // ndef __GINAC_SERIES_H__