]> www.ginac.de Git - ginac.git/blob - ginac/ncmul.h
Hunted down some output bugs. Hope it can be safely piped into Maple now.
[ginac.git] / ginac / ncmul.h
1 /** @file ncmul.h
2  *
3  *  Interface to GiNaC's non-commutative products of expressions. */
4
5 #ifndef _NCMUL_H_
6 #define _NCMUL_H_
7
8 #include "exprseq.h"
9
10 class ncmul;
11
12 /** Non-commutative product of expressions. */
13 class ncmul : public exprseq
14 {
15     friend class power;
16     friend ex nonsimplified_ncmul(exvector const & v);
17     friend ex simplified_ncmul(exvector const & v);
18
19 // member functions
20
21     // default constructor, destructor, copy constructor assignment operator and helpers
22 public:
23     ncmul();
24     ~ncmul();
25     ncmul(ncmul const & other);
26     ncmul const & operator=(ncmul const & other);
27 protected:
28     void copy(ncmul const & other);
29     void destroy(bool call_parent);
30
31     // other constructors
32 public:
33     ncmul(ex const & lh, ex const & rh);
34     ncmul(ex const & f1, ex const & f2, ex const & f3);
35     ncmul(ex const & f1, ex const & f2, ex const & f3,
36           ex const & f4);
37     ncmul(ex const & f1, ex const & f2, ex const & f3,
38           ex const & f4, ex const & f5);
39     ncmul(ex const & f1, ex const & f2, ex const & f3,
40           ex const & f4, ex const & f5, ex const & f6);
41     ncmul(exvector const & v, bool discardable=false);
42     ncmul(exvector * vp); // vp will be deleted
43
44     // functions overriding virtual functions from bases classes
45 public:
46     basic * duplicate() const;
47     void printraw(ostream & os) const;
48     void print(ostream & os, unsigned upper_precedence) const;
49     void printcsrc(ostream & os, unsigned upper_precedence) const;
50     bool info(unsigned inf) const;
51     int degree(symbol const & s) const;
52     int ldegree(symbol const & s) const;
53     ex expand(unsigned options=0) const;
54     ex coeff(symbol const & s, int const n=1) const;
55     ex eval(int level=0) const;
56     ex diff(symbol const & s) const;
57     ex subs(lst const & ls, lst const & lr) const;
58     exvector get_indices(void) const;
59     ex thisexprseq(exvector const & v) const;
60     ex thisexprseq(exvector * vp) const;
61 protected:
62     int compare_same_type(basic const & other) const;
63     unsigned return_type(void) const;
64     unsigned return_type_tinfo(void) const;
65     
66     // new virtual functions which can be overridden by derived classes
67     // none
68
69     // non-virtual functions in this class
70 protected:
71     unsigned count_factors(ex const & e) const;
72     void append_factors(exvector & v, ex const & e) const;
73     exvector expandchildren(unsigned options) const;
74 public:
75     exvector const & get_factors(void) const;
76
77 // member variables
78
79 protected:
80     static unsigned precedence;
81 };
82
83 // global constants
84
85 extern const ncmul some_ncmul;
86 extern type_info const & typeid_ncmul;
87
88 // friend funtions 
89
90 ex nonsimplified_ncmul(exvector const & v);
91 ex simplified_ncmul(exvector const & v);
92
93 #define ex_to_ncmul(X) static_cast<ncmul const &>(*(X).bp)
94
95 #endif // ndef _NCMUL_H_
96