]> www.ginac.de Git - ginac.git/blob - ginac/ncmul.h
- check program is not built until you say "make check"
[ginac.git] / ginac / ncmul.h
1 /** @file ncmul.h
2  *
3  *  Interface to GiNaC's non-commutative products 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_NCMUL_H__
23 #define __GINAC_NCMUL_H__
24
25 #include <ginac/exprseq.h>
26
27 /** Non-commutative product of expressions. */
28 class ncmul : public exprseq
29 {
30     friend class power;
31     friend ex nonsimplified_ncmul(exvector const & v);
32     friend ex simplified_ncmul(exvector const & v);
33
34 // member functions
35
36     // default constructor, destructor, copy constructor assignment operator and helpers
37 public:
38     ncmul();
39     ~ncmul();
40     ncmul(ncmul const & other);
41     ncmul const & operator=(ncmul const & other);
42 protected:
43     void copy(ncmul const & other);
44     void destroy(bool call_parent);
45
46     // other constructors
47 public:
48     ncmul(ex const & lh, ex const & rh);
49     ncmul(ex const & f1, ex const & f2, ex const & f3);
50     ncmul(ex const & f1, ex const & f2, ex const & f3,
51           ex const & f4);
52     ncmul(ex const & f1, ex const & f2, ex const & f3,
53           ex const & f4, ex const & f5);
54     ncmul(ex const & f1, ex const & f2, ex const & f3,
55           ex const & f4, ex const & f5, ex const & f6);
56     ncmul(exvector const & v, bool discardable=false);
57     ncmul(exvector * vp); // vp will be deleted
58
59     // functions overriding virtual functions from bases classes
60 public:
61     basic * duplicate() const;
62     void printraw(ostream & os) const;
63     void print(ostream & os, unsigned upper_precedence) const;
64     void printcsrc(ostream & os, unsigned upper_precedence) const;
65     bool info(unsigned inf) const;
66     int degree(symbol const & s) const;
67     int ldegree(symbol const & s) const;
68     ex expand(unsigned options=0) const;
69     ex coeff(symbol const & s, int const n=1) const;
70     ex eval(int level=0) const;
71     ex diff(symbol const & s) const;
72     ex subs(lst const & ls, lst const & lr) const;
73     exvector get_indices(void) const;
74     ex thisexprseq(exvector const & v) const;
75     ex thisexprseq(exvector * vp) const;
76 protected:
77     int compare_same_type(basic const & other) const;
78     unsigned return_type(void) const;
79     unsigned return_type_tinfo(void) const;
80     
81     // new virtual functions which can be overridden by derived classes
82     // none
83
84     // non-virtual functions in this class
85 protected:
86     unsigned count_factors(ex const & e) const;
87     void append_factors(exvector & v, ex const & e) const;
88     exvector expandchildren(unsigned options) const;
89 public:
90     exvector const & get_factors(void) const;
91
92 // member variables
93
94 protected:
95     static unsigned precedence;
96 };
97
98 // global constants
99
100 extern const ncmul some_ncmul;
101 extern type_info const & typeid_ncmul;
102
103 // friend funtions 
104
105 ex nonsimplified_ncmul(exvector const & v);
106 ex simplified_ncmul(exvector const & v);
107
108 #define ex_to_ncmul(X) static_cast<ncmul const &>(*(X).bp)
109
110 #endif // ndef __GINAC_NCMUL_H__
111