]> www.ginac.de Git - ginac.git/blob - ginac/add.h
783830345b682f4d18ee7bcd6741fc6a77e4104e
[ginac.git] / ginac / add.h
1 /** @file add.h
2  *
3  *  Interface to GiNaC's sums of expressions.
4  *
5  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #ifndef __GINAC_ADD_H__
23 #define __GINAC_ADD_H__
24
25 /** Sum of expressions. */
26 class add : public expairseq
27 {
28     friend class mul;
29     friend class ncmul;
30     friend class power;
31
32 // member functions
33
34     // default constructor, destructor, copy constructor assignment operator and helpers
35 public:
36     add();
37     ~add();
38     add(add const & other);
39     add const & operator=(add const & other);
40 protected:
41     void copy(add const & other);
42     void destroy(bool call_parent);
43
44     // other constructors
45 public:
46     add(ex const & lh, ex const & rh);
47     add(exvector const & v);
48     add(epvector const & v);
49     //add(epvector const & v, bool do_not_canonicalize=0);
50     add(epvector const & v, ex const & oc);
51     add(epvector * vp, ex const & oc);
52
53     // functions overriding virtual functions from bases classes
54 public:
55     basic * duplicate() const;
56     void printraw(ostream & os) const;
57     void print(ostream & os, unsigned upper_precedence=0) const;
58     void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
59     bool info(unsigned inf) const;
60     int degree(symbol const & s) const;
61     int ldegree(symbol const & s) const;
62     ex coeff(symbol const & s, int const n=1) const;
63     ex eval(int level=0) const;
64     ex diff(symbol const & s) const;
65     ex series(symbol const & s, ex const & point, int order) const;
66     ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
67     numeric integer_content(void) const;
68     ex smod(numeric const &xi) const;
69     numeric max_coefficient(void) const;
70     exvector get_indices(void) const;
71     ex simplify_ncmul(exvector const & v) const;
72 protected:
73     int compare_same_type(basic const & other) const;
74     bool is_equal_same_type(basic const & other) const;
75     unsigned return_type(void) const;
76     unsigned return_type_tinfo(void) const;
77     ex thisexpairseq(epvector const & v, ex const & oc) const;
78     ex thisexpairseq(epvector * vp, ex const & oc) const;
79     void printpair(ostream & os, expair const & p,
80                    unsigned upper_precedence) const;
81     expair split_ex_to_pair(ex const & e) const;
82     expair combine_ex_with_coeff_to_pair(ex const & e,
83                                          ex const & c) const;
84     expair combine_pair_with_coeff_to_pair(expair const & p,
85                                            ex const & c) const;
86     ex recombine_pair_to_ex(expair const & p) const;
87     ex expand(unsigned options=0) const;
88     
89     // new virtual functions which can be overridden by derived classes
90     // none
91     
92     // non-virtual functions in this class
93     // none
94
95 // member variables
96
97 protected:
98     static unsigned precedence;
99 };
100
101 // global constants
102
103 extern const add some_add;
104 extern type_info const & typeid_add;
105
106 #define ex_to_add(X) static_cast<add const &>(*(X).bp)
107
108 #endif // ndef __GINAC_ADD_H__
109