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