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