3 * Interface to GiNaC's non-commutative products of expressions. */
6 * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
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.
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.
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
23 #ifndef __GINAC_NCMUL_H__
24 #define __GINAC_NCMUL_H__
30 /** Non-commutative product of expressions. */
31 class ncmul : public exprseq
33 GINAC_DECLARE_REGISTERED_CLASS(ncmul, exprseq)
36 friend ex nonsimplified_ncmul(const exvector & v);
37 friend ex simplified_ncmul(const exvector & v);
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,
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
54 // functions overriding virtual functions from base classes
56 void print(const print_context & c, unsigned level = 0) const;
57 unsigned precedence(void) const {return 50;}
58 bool info(unsigned inf) const;
59 int degree(const ex & s) const;
60 int ldegree(const ex & s) const;
61 ex expand(unsigned options=0) const;
62 ex coeff(const ex & s, int n=1) const;
63 ex eval(int level=0) const;
65 exvector get_free_indices(void) const;
66 ex thisexprseq(const exvector & v) const;
67 ex thisexprseq(exvector * vp) const;
69 ex derivative(const symbol & s) const;
70 unsigned return_type(void) const;
71 unsigned return_type_tinfo(void) const;
73 // new virtual functions which can be overridden by derived classes
76 // non-virtual functions in this class
78 unsigned count_factors(const ex & e) const;
79 void append_factors(exvector & v, const ex & e) const;
80 exvector expandchildren(unsigned options) const;
82 const exvector & get_factors(void) const;
87 ex nonsimplified_ncmul(const exvector & v);
88 ex simplified_ncmul(const exvector & v);
92 /** Return the ncmul object handled by an ex. Deprecated: use ex_to<ncmul>().
93 * This is unsafe: you need to check the type first. */
94 inline const ncmul &ex_to_ncmul(const ex &e)
96 return static_cast <const ncmul &>(*e.bp);
99 /** Specialization of is_exactly_a<ncmul>(obj) for ncmul objects. */
100 template<> inline bool is_exactly_a<ncmul>(const basic & obj)
102 return obj.tinfo()==TINFO_ncmul;
107 #endif // ndef __GINAC_NCMUL_H__