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