GiNaC  1.8.0
pseries.h
Go to the documentation of this file.
1 
5 /*
6  * GiNaC Copyright (C) 1999-2020 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef GINAC_SERIES_H
24 #define GINAC_SERIES_H
25 
26 #include "basic.h"
27 #include "expairseq.h"
28 
29 namespace GiNaC {
30 
35 class pseries : public basic
36 {
38 
39  // other constructors
40 public:
41  pseries(const ex &rel_, const epvector &ops_);
42  pseries(const ex &rel_, epvector &&ops_);
43 
44  // functions overriding virtual functions from base classes
45 public:
46  unsigned precedence() const override {return 38;} // for clarity just below add::precedence
47  size_t nops() const override;
48  ex op(size_t i) const override;
49  int degree(const ex &s) const override;
50  int ldegree(const ex &s) const override;
51  ex coeff(const ex &s, int n = 1) const override;
52  ex collect(const ex &s, bool distributed = false) const override;
53  ex eval() const override;
54  ex evalf() const override;
55  ex series(const relational & r, int order, unsigned options = 0) const override;
56  ex subs(const exmap & m, unsigned options = 0) const override;
57  ex normal(exmap & repl, exmap & rev_lookup, lst & modifier) const override;
58  ex expand(unsigned options = 0) const override;
59  ex conjugate() const override;
60  ex real_part() const override;
61  ex imag_part() const override;
62  ex eval_integ() const override;
63  ex evalm() const override;
65  void archive(archive_node& n) const override;
67  void read_archive(const archive_node& n, lst& syms) override;
68 protected:
69  ex derivative(const symbol & s) const override;
70 
71  // non-virtual functions in this class
72 public:
74  ex get_var() const {return var;}
75 
77  ex get_point() const {return point;}
78 
82  ex convert_to_poly(bool no_order = false) const;
83 
86  bool is_compatible_to(const pseries &other) const {return var.is_equal(other.var) && point.is_equal(other.point);}
87 
89  bool is_zero() const {return seq.size() == 0;}
90 
93  bool is_terminating() const;
94 
96  ex coeffop(size_t i) const;
97  ex exponop(size_t i) const;
98 
99  ex add_series(const pseries &other) const;
100  ex mul_const(const numeric &other) const;
101  ex mul_series(const pseries &other) const;
102  ex power_const(const numeric &p, int deg) const;
103  pseries shift_exponents(int deg) const;
104 
105 protected:
106  void print_series(const print_context & c, const char *openbrace, const char *closebrace, const char *mul_sym, const char *pow_sym, unsigned level) const;
107  void do_print(const print_context & c, unsigned level) const;
108  void do_print_latex(const print_latex & c, unsigned level) const;
109  void do_print_tree(const print_tree & c, unsigned level) const;
110  void do_print_python(const print_python & c, unsigned level) const;
111  void do_print_python_repr(const print_python_repr & c, unsigned level) const;
112 
113 protected:
116 
119 
122 };
124 
125 
126 // utility functions
127 
136 inline ex series_to_poly(const ex &e)
137 {
138  return (ex_to<pseries>(e).convert_to_poly(true));
139 }
140 
141 inline bool is_terminating(const pseries & s)
142 {
143  return s.is_terminating();
144 }
145 
146 } // namespace GiNaC
147 
148 #endif // ndef GINAC_SERIES_H
ex power_const(const numeric &p, int deg) const
Compute the p-th power of a series.
Definition: pseries.cpp:976
ex coeff(const ex &s, int n=1) const override
Return coefficient of degree n in power series if s is the expansion variable.
Definition: pseries.cpp:357
void do_print(const print_context &c, unsigned level) const
Definition: pseries.cpp:212
ex expand(unsigned options=0) const override
Implementation of ex::expand() for a power series.
Definition: pseries.cpp:527
exset syms
Definition: factor.cpp:2434
ex mul_const(const numeric &other) const
Multiply a pseries object with a numeric constant, producing a pseries object that represents the pro...
Definition: pseries.cpp:779
int degree(const ex &s) const override
Return degree of highest power of the series.
Definition: pseries.cpp:315
void print_series(const print_context &c, const char *openbrace, const char *closebrace, const char *mul_sym, const char *pow_sym, unsigned level) const
Definition: pseries.cpp:153
ex conjugate() const override
Definition: pseries.cpp:412
ex derivative(const symbol &s) const override
Implementation of ex::diff() for a power series.
Definition: pseries.cpp:540
void do_print_latex(const print_latex &c, unsigned level) const
Definition: pseries.cpp:217
bool is_equal(const ex &other) const
Definition: ex.h:345
pseries(const ex &rel_, const epvector &ops_)
Construct pseries from a vector of coefficients and powers.
Definition: pseries.cpp:71
ex exponop(size_t i) const
Definition: pseries.cpp:598
Definition: add.cpp:38
ex real_part() const override
Definition: pseries.cpp:427
ex evalf() const override
Evaluate coefficients numerically.
Definition: pseries.cpp:401
This class holds a relation consisting of two expressions and a logical relation between them...
Definition: relational.h:34
bool is_terminating(const pseries &s)
Definition: pseries.h:141
Interface to sequences of expression pairs.
This class is the ABC (abstract base class) of GiNaC&#39;s class hierarchy.
Definition: basic.h:104
ex imag_part() const override
Definition: pseries.cpp:442
Context for python-parsable output.
Definition: print.h:138
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Definition: pseries.cpp:242
bool is_terminating() const
Returns true if there is no order term, i.e.
Definition: pseries.cpp:586
ex convert_to_poly(bool no_order=false) const
Convert the pseries object to an ordinary polynomial.
Definition: pseries.cpp:573
ex get_var() const
Get the expansion variable.
Definition: pseries.h:74
pseries shift_exponents(int deg) const
Return a new pseries object with the powers shifted by deg.
Definition: pseries.cpp:1061
ex collect(const ex &s, bool distributed=false) const override
Does nothing.
Definition: pseries.cpp:389
size_t r
Definition: factor.cpp:770
Context for python pretty-print output.
Definition: print.h:130
ex series(const relational &r, int order, unsigned options=0) const override
Re-expansion of a pseries object.
Definition: pseries.cpp:1169
void do_print_python(const print_python &c, unsigned level) const
Definition: pseries.cpp:222
ex normal(exmap &repl, exmap &rev_lookup, lst &modifier) const override
Implementation of ex::normal() for pseries.
Definition: normal.cpp:2465
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Definition: numeric.h:81
Context for latex-parsable output.
Definition: print.h:122
ex eval() const override
Perform coefficient-wise automatic term rewriting rules in this class.
Definition: pseries.cpp:395
void do_print_tree(const print_tree &c, unsigned level) const
Definition: pseries.cpp:227
ex coeffop(size_t i) const
Get coefficients and exponents.
Definition: pseries.cpp:591
ex get_point() const
Get the expansion point.
Definition: pseries.h:77
unsigned options
Definition: factor.cpp:2480
ex eval_integ() const override
Evaluate integrals, if result is known.
Definition: pseries.cpp:457
mvec m
Definition: factor.cpp:771
ex var
Series variable (holds a symbol)
Definition: pseries.h:118
This class holds a extended truncated power series (positive and negative integer powers)...
Definition: pseries.h:35
bool is_compatible_to(const pseries &other) const
Check whether series is compatible to another series (expansion variable and point are the same...
Definition: pseries.h:86
ex evalm() const override
Evaluate sums, products and integer powers of matrices.
Definition: pseries.cpp:481
std::map< ex, ex, ex_is_less > exmap
Definition: basic.h:50
ex point
Expansion point.
Definition: pseries.h:121
ex add_series(const pseries &other) const
Add one series object to another, producing a pseries object that represents the sum.
Definition: pseries.cpp:681
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: pseries.cpp:119
ex op(size_t i) const override
Return the ith term in the series when represented as a sum.
Definition: pseries.cpp:302
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
Definition: pseries.h:46
size_t n
Definition: factor.cpp:1463
Base class for print_contexts.
Definition: print.h:102
ex series_to_poly(const ex &e)
Convert the pseries object embedded in an expression to an ordinary polynomial in the expansion varia...
Definition: pseries.h:136
Interface to GiNaC&#39;s ABC.
size_t nops() const override
Return the number of operands including a possible order term.
Definition: pseries.cpp:296
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:48
Lightweight wrapper for GiNaC&#39;s symbolic objects.
Definition: ex.h:72
int ldegree(const ex &s) const override
Return degree of lowest power of the series.
Definition: pseries.cpp:335
int order
Basic CAS symbol.
Definition: symbol.h:38
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
ex mul_series(const pseries &other) const
Multiply one pseries object to another, producing a pseries object that represents the product...
Definition: pseries.cpp:799
void archive(archive_node &n) const override
Save (a.k.a.
Definition: pseries.cpp:137
std::vector< expair > epvector
expair-vector
Definition: expairseq.h:33
GINAC_DECLARE_UNARCHIVER(add)
bool is_zero() const
Check whether series has the value zero.
Definition: pseries.h:89
size_t c
Definition: factor.cpp:770
epvector seq
Vector of {coefficient, power} pairs.
Definition: pseries.h:115
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
Definition: pseries.cpp:508
Context for tree-like output for debugging.
Definition: print.h:146

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.