| 1 |
cbauer |
1.1 |
/** @file ncmul.h
|
| 2 |
|
|
*
|
| 3 |
cbauer |
1.4 |
* Interface to GiNaC's non-commutative products of expressions. */
|
| 4 |
|
|
|
| 5 |
|
|
/*
|
| 6 |
kreckel |
1.19 |
* GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
|
| 7 |
cbauer |
1.2 |
*
|
| 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 |
cbauer |
1.1 |
|
| 23 |
cbauer |
1.2 |
#ifndef __GINAC_NCMUL_H__
|
| 24 |
|
|
#define __GINAC_NCMUL_H__
|
| 25 |
cbauer |
1.1 |
|
| 26 |
cbauer |
1.11 |
#include "exprseq.h"
|
| 27 |
cbauer |
1.3 |
|
| 28 |
cbauer |
1.5 |
namespace GiNaC {
|
| 29 |
|
|
|
| 30 |
cbauer |
1.1 |
/** Non-commutative product of expressions. */
|
| 31 |
|
|
class ncmul : public exprseq
|
| 32 |
|
|
{
|
| 33 |
cbauer |
1.15 |
GINAC_DECLARE_REGISTERED_CLASS(ncmul, exprseq)
|
| 34 |
cbauer |
1.9 |
|
| 35 |
cbauer |
1.15 |
friend class power;
|
| 36 |
|
|
friend ex nonsimplified_ncmul(const exvector & v);
|
| 37 |
|
|
friend ex simplified_ncmul(const exvector & v);
|
| 38 |
cbauer |
1.1 |
|
| 39 |
|
|
// member functions
|
| 40 |
|
|
|
| 41 |
cbauer |
1.15 |
// other constructors
|
| 42 |
cbauer |
1.1 |
public:
|
| 43 |
cbauer |
1.15 |
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 |
cbauer |
1.16 |
const ex & f4);
|
| 47 |
cbauer |
1.15 |
ncmul(const ex & f1, const ex & f2, const ex & f3,
|
| 48 |
cbauer |
1.16 |
const ex & f4, const ex & f5);
|
| 49 |
cbauer |
1.15 |
ncmul(const ex & f1, const ex & f2, const ex & f3,
|
| 50 |
cbauer |
1.16 |
const ex & f4, const ex & f5, const ex & f6);
|
| 51 |
cbauer |
1.15 |
ncmul(const exvector & v, bool discardable=false);
|
| 52 |
|
|
ncmul(exvector * vp); // vp will be deleted
|
| 53 |
cbauer |
1.1 |
|
| 54 |
cbauer |
1.15 |
// functions overriding virtual functions from bases classes
|
| 55 |
cbauer |
1.1 |
public:
|
| 56 |
cbauer |
1.26 |
void print(const print_context & c, unsigned level = 0) const;
|
| 57 |
cbauer |
1.28 |
unsigned precedence(void) const {return 50;}
|
| 58 |
cbauer |
1.15 |
bool info(unsigned inf) const;
|
| 59 |
cbauer |
1.25 |
int degree(const ex & s) const;
|
| 60 |
|
|
int ldegree(const ex & s) const;
|
| 61 |
cbauer |
1.15 |
ex expand(unsigned options=0) const;
|
| 62 |
cbauer |
1.25 |
ex coeff(const ex & s, int n=1) const;
|
| 63 |
cbauer |
1.15 |
ex eval(int level=0) const;
|
| 64 |
cbauer |
1.29 |
ex evalm(void) const;
|
| 65 |
cbauer |
1.24 |
exvector get_free_indices(void) const;
|
| 66 |
cbauer |
1.15 |
ex thisexprseq(const exvector & v) const;
|
| 67 |
|
|
ex thisexprseq(exvector * vp) const;
|
| 68 |
cbauer |
1.1 |
protected:
|
| 69 |
cbauer |
1.15 |
ex derivative(const symbol & s) const;
|
| 70 |
|
|
unsigned return_type(void) const;
|
| 71 |
|
|
unsigned return_type_tinfo(void) const;
|
| 72 |
|
|
|
| 73 |
|
|
// new virtual functions which can be overridden by derived classes
|
| 74 |
|
|
// none
|
| 75 |
cbauer |
1.1 |
|
| 76 |
cbauer |
1.15 |
// non-virtual functions in this class
|
| 77 |
cbauer |
1.1 |
protected:
|
| 78 |
cbauer |
1.15 |
unsigned count_factors(const ex & e) const;
|
| 79 |
|
|
void append_factors(exvector & v, const ex & e) const;
|
| 80 |
|
|
exvector expandchildren(unsigned options) const;
|
| 81 |
cbauer |
1.1 |
public:
|
| 82 |
cbauer |
1.15 |
const exvector & get_factors(void) const;
|
| 83 |
cbauer |
1.1 |
};
|
| 84 |
|
|
|
| 85 |
|
|
// friend funtions
|
| 86 |
|
|
|
| 87 |
cbauer |
1.10 |
ex nonsimplified_ncmul(const exvector & v);
|
| 88 |
|
|
ex simplified_ncmul(const exvector & v);
|
| 89 |
cbauer |
1.1 |
|
| 90 |
cbauer |
1.5 |
// utility functions
|
| 91 |
kreckel |
1.30 |
|
| 92 |
kreckel |
1.31 |
/** Return the ncmul object handled by an ex. Deprecated: use ex_to<ncmul>().
|
| 93 |
kreckel |
1.30 |
* This is unsafe: you need to check the type first. */
|
| 94 |
cbauer |
1.5 |
inline const ncmul &ex_to_ncmul(const ex &e)
|
| 95 |
|
|
{
|
| 96 |
|
|
return static_cast <const ncmul &>(*e.bp);
|
| 97 |
kreckel |
1.30 |
}
|
| 98 |
|
|
|
| 99 |
|
|
/** Specialization of is_exactly_a<ncmul>(obj) for ncmul objects. */
|
| 100 |
|
|
template<> inline bool is_exactly_a<ncmul>(const basic & obj)
|
| 101 |
|
|
{
|
| 102 |
|
|
return obj.tinfo()==TINFO_ncmul;
|
| 103 |
cbauer |
1.5 |
}
|
| 104 |
|
|
|
| 105 |
|
|
} // namespace GiNaC
|
| 106 |
cbauer |
1.1 |
|
| 107 |
cbauer |
1.2 |
#endif // ndef __GINAC_NCMUL_H__
|