| 1 |
cbauer |
1.1 |
/** @file add.h
|
| 2 |
|
|
*
|
| 3 |
cbauer |
1.4 |
* Interface to GiNaC's sums of expressions. */
|
| 4 |
|
|
|
| 5 |
|
|
/*
|
| 6 |
kreckel |
1.21 |
* 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_ADD_H__
|
| 24 |
|
|
#define __GINAC_ADD_H__
|
| 25 |
cbauer |
1.1 |
|
| 26 |
cbauer |
1.13 |
#include "expairseq.h"
|
| 27 |
cbauer |
1.3 |
|
| 28 |
cbauer |
1.5 |
namespace GiNaC {
|
| 29 |
|
|
|
| 30 |
cbauer |
1.1 |
/** Sum of expressions. */
|
| 31 |
|
|
class add : public expairseq
|
| 32 |
|
|
{
|
| 33 |
cbauer |
1.19 |
GINAC_DECLARE_REGISTERED_CLASS(add, expairseq)
|
| 34 |
kreckel |
1.25 |
|
| 35 |
cbauer |
1.19 |
friend class mul;
|
| 36 |
|
|
friend class ncmul;
|
| 37 |
|
|
friend class power;
|
| 38 |
kreckel |
1.25 |
|
| 39 |
cbauer |
1.19 |
// other constructors
|
| 40 |
cbauer |
1.1 |
public:
|
| 41 |
cbauer |
1.19 |
add(const ex & lh, const ex & rh);
|
| 42 |
|
|
add(const exvector & v);
|
| 43 |
|
|
add(const epvector & v);
|
| 44 |
|
|
add(const epvector & v, const ex & oc);
|
| 45 |
|
|
add(epvector * vp, const ex & oc);
|
| 46 |
kreckel |
1.25 |
|
| 47 |
cbauer |
1.19 |
// functions overriding virtual functions from bases classes
|
| 48 |
cbauer |
1.1 |
public:
|
| 49 |
cbauer |
1.28 |
void print(const print_context & c, unsigned level = 0) const;
|
| 50 |
cbauer |
1.29 |
unsigned precedence(void) const {return 40;}
|
| 51 |
cbauer |
1.19 |
bool info(unsigned inf) const;
|
| 52 |
cbauer |
1.27 |
int degree(const ex & s) const;
|
| 53 |
|
|
int ldegree(const ex & s) const;
|
| 54 |
|
|
ex coeff(const ex & s, int n=1) const;
|
| 55 |
cbauer |
1.19 |
ex eval(int level=0) const;
|
| 56 |
cbauer |
1.30 |
ex evalm(void) const;
|
| 57 |
cbauer |
1.19 |
ex series(const relational & r, int order, unsigned options = 0) const;
|
| 58 |
|
|
ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
|
| 59 |
|
|
numeric integer_content(void) const;
|
| 60 |
|
|
ex smod(const numeric &xi) const;
|
| 61 |
|
|
numeric max_coefficient(void) const;
|
| 62 |
cbauer |
1.26 |
exvector get_free_indices(void) const;
|
| 63 |
cbauer |
1.19 |
ex simplify_ncmul(const exvector & v) const;
|
| 64 |
cbauer |
1.1 |
protected:
|
| 65 |
cbauer |
1.19 |
ex derivative(const symbol & s) const;
|
| 66 |
|
|
bool is_equal_same_type(const basic & other) const;
|
| 67 |
|
|
unsigned return_type(void) const;
|
| 68 |
|
|
unsigned return_type_tinfo(void) const;
|
| 69 |
|
|
ex thisexpairseq(const epvector & v, const ex & oc) const;
|
| 70 |
|
|
ex thisexpairseq(epvector * vp, const ex & oc) const;
|
| 71 |
|
|
expair split_ex_to_pair(const ex & e) const;
|
| 72 |
|
|
expair combine_ex_with_coeff_to_pair(const ex & e,
|
| 73 |
kreckel |
1.25 |
const ex & c) const;
|
| 74 |
cbauer |
1.19 |
expair combine_pair_with_coeff_to_pair(const expair & p,
|
| 75 |
kreckel |
1.25 |
const ex & c) const;
|
| 76 |
cbauer |
1.19 |
ex recombine_pair_to_ex(const expair & p) const;
|
| 77 |
|
|
ex expand(unsigned options=0) const;
|
| 78 |
cbauer |
1.1 |
};
|
| 79 |
|
|
|
| 80 |
cbauer |
1.5 |
// utility functions
|
| 81 |
kreckel |
1.31 |
|
| 82 |
kreckel |
1.32 |
/** Return the add object handled by an ex. Deprecated: use ex_to<add>().
|
| 83 |
kreckel |
1.31 |
* This is unsafe: you need to check the type first. */
|
| 84 |
cbauer |
1.5 |
inline const add &ex_to_add(const ex &e)
|
| 85 |
|
|
{
|
| 86 |
|
|
return static_cast<const add &>(*e.bp);
|
| 87 |
kreckel |
1.31 |
}
|
| 88 |
|
|
|
| 89 |
|
|
/** Specialization of is_exactly_a<add>(obj) for add objects. */
|
| 90 |
|
|
template<> inline bool is_exactly_a<add>(const basic & obj)
|
| 91 |
|
|
{
|
| 92 |
|
|
return obj.tinfo()==TINFO_add;
|
| 93 |
cbauer |
1.5 |
}
|
| 94 |
|
|
|
| 95 |
|
|
} // namespace GiNaC
|
| 96 |
cbauer |
1.1 |
|
| 97 |
cbauer |
1.2 |
#endif // ndef __GINAC_ADD_H__
|