]> www.ginac.de Git - ginac.git/blob - ginac/add.h
d4da3beabea7b7f786de1b12872c2d0eb60c2d88
[ginac.git] / ginac / add.h
1 /** @file add.h
2  *
3  *  Interface to GiNaC's sums of expressions. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2000 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __GINAC_ADD_H__
24 #define __GINAC_ADD_H__
25
26 #include <ginac/expairseq.h>
27
28 #ifndef NO_GINAC_NAMESPACE
29 namespace GiNaC {
30 #endif // ndef NO_GINAC_NAMESPACE
31
32 /** Sum of expressions. */
33 class add : public expairseq
34 {
35     GINAC_DECLARE_REGISTERED_CLASS(add, expairseq)
36
37     friend class mul;
38     friend class ncmul;
39     friend class power;
40
41 // member functions
42
43     // default constructor, destructor, copy constructor assignment operator and helpers
44 public:
45     add();
46     ~add();
47     add(add const & other);
48     add const & operator=(add const & other);
49 protected:
50     void copy(add const & other);
51     void destroy(bool call_parent);
52
53     // other constructors
54 public:
55     add(ex const & lh, ex const & rh);
56     add(exvector const & v);
57     add(epvector const & v);
58     //add(epvector const & v, bool do_not_canonicalize=0);
59     add(epvector const & v, ex const & oc);
60     add(epvector * vp, ex const & oc);
61
62     // functions overriding virtual functions from bases classes
63 public:
64     basic * duplicate() const;
65     void print(ostream & os, unsigned upper_precedence=0) const;
66     void printraw(ostream & os) const;
67     void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
68     bool info(unsigned inf) const;
69     int degree(symbol const & s) const;
70     int ldegree(symbol const & s) const;
71     ex coeff(symbol const & s, int const n=1) const;
72     ex eval(int level=0) const;
73     ex diff(symbol const & s) const;
74     ex series(symbol const & s, ex const & point, int order) const;
75     ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
76     numeric integer_content(void) const;
77     ex smod(const numeric &xi) const;
78     numeric max_coefficient(void) const;
79     exvector get_indices(void) const;
80     ex simplify_ncmul(exvector const & v) const;
81 protected:
82     int compare_same_type(basic const & other) const;
83     bool is_equal_same_type(basic const & other) const;
84     unsigned return_type(void) const;
85     unsigned return_type_tinfo(void) const;
86     ex thisexpairseq(epvector const & v, ex const & oc) const;
87     ex thisexpairseq(epvector * vp, ex const & oc) const;
88     expair split_ex_to_pair(ex const & e) const;
89     expair combine_ex_with_coeff_to_pair(ex const & e,
90                                          ex const & c) const;
91     expair combine_pair_with_coeff_to_pair(expair const & p,
92                                            ex const & c) const;
93     ex recombine_pair_to_ex(expair const & p) const;
94     ex expand(unsigned options=0) const;
95     
96     // new virtual functions which can be overridden by derived classes
97     // none
98     
99     // non-virtual functions in this class
100     // none
101
102 // member variables
103
104 protected:
105     static unsigned precedence;
106 };
107
108 // global constants
109
110 extern const add some_add;
111 extern type_info const & typeid_add;
112
113 // utility functions
114 inline const add &ex_to_add(const ex &e)
115 {
116         return static_cast<const add &>(*e.bp);
117 }
118
119 #ifndef NO_GINAC_NAMESPACE
120 } // namespace GiNaC
121 #endif // ndef NO_GINAC_NAMESPACE
122
123 #endif // ndef __GINAC_ADD_H__