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