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