|
| 1 | +/** @file add.h |
| 2 | + * |
| 3 | + * Interface to GiNaC's sums of expressions. */ |
| 4 | + |
| 5 | +/* |
| 6 | + * GiNaC Copyright (C) 1999-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | + */ |
| 22 | + |
| 23 | +#ifndef __GINAC_ADD_H__ |
| 24 | +#define __GINAC_ADD_H__ |
| 25 | + |
| 26 | +#include "expairseq.h" |
| 27 | + |
| 28 | +namespace GiNaC { |
| 29 | + |
| 30 | +/** Sum of expressions. */ |
| 31 | +class add : public expairseq |
| 32 | +{ |
| 33 | + GINAC_DECLARE_REGISTERED_CLASS(add, expairseq) |
| 34 | + |
| 35 | + friend class ex; |
| 36 | + friend class mul; |
| 37 | + friend class power; |
| 38 | + friend ex Power(const ex& base_, const ex& expo_); |
| 39 | + |
| 40 | + // other constructors |
| 41 | +public: |
| 42 | + add(const ex & lh, const ex & rh); |
| 43 | + add(const exvector & v, bool hold=false); |
| 44 | + add(const epvector & v); |
| 45 | + add(const epvector & v, const numeric & oc); |
| 46 | +// add(std::unique_ptr<epvector> vp, const ex & oc); |
| 47 | + static ex unarchive(const archive_node &n, lst &sym_lst) |
| 48 | + { |
| 49 | + return (new add(n, sym_lst))-> |
| 50 | + setflag(status_flags::dynallocated); |
| 51 | + } |
| 52 | + |
| 53 | + // functions overriding virtual functions from base classes |
| 54 | +public: |
| 55 | + unsigned precedence() const override {return 40;} |
| 56 | + bool info(unsigned inf) const override; |
| 57 | + bool is_polynomial(const ex & var) const override; |
| 58 | + numeric degree(const ex & s) const override; |
| 59 | + numeric ldegree(const ex & s) const override; |
| 60 | + ex coeff(const ex & s, const ex & n) const override; |
| 61 | + ex eval(int level=0) const override; |
| 62 | + ex series(const relational & r, int order, unsigned options = 0) const override; |
| 63 | + void useries(flint_series_t& fp, int order) const override; |
| 64 | + ex normal(exmap & repl, exmap & rev_lookup, int level=0, unsigned options = 0) const override; |
| 65 | + numeric integer_content() const override; |
| 66 | + ex smod(const numeric &xi) const override; |
| 67 | + numeric max_coefficient() const override; |
| 68 | + ex conjugate() const override; |
| 69 | + ex real_part() const override; |
| 70 | + ex imag_part() const override; |
| 71 | + const epvector & get_sorted_seq() const override; |
| 72 | + ex lead_coeff() const; |
| 73 | +protected: |
| 74 | + ex derivative(const symbol & s) const override; |
| 75 | + unsigned return_type() const override; |
| 76 | + tinfo_t return_type_tinfo() const override; |
| 77 | + ex thisexpairseq(const epvector & v, const numeric & oc, bool do_index_renaming = false) const override; |
| 78 | + ex thisexpairseq(std::unique_ptr<epvector> vp, const numeric & oc, bool do_index_renaming = false) const override; |
| 79 | + expair split_ex_to_pair(const ex & e) const override; |
| 80 | + expair combine_ex_with_coeff_to_pair(const ex & e, |
| 81 | + const numeric & c) const override; |
| 82 | + expair combine_pair_with_coeff_to_pair(const expair & p, |
| 83 | + const numeric & c) const override; |
| 84 | + ex recombine_pair_to_ex(const expair & p) const override; |
| 85 | + ex power(const numeric& expo) const; |
| 86 | + ex expand(unsigned options=0) const override; |
| 87 | + ex eval_infinity(epvector::const_iterator infinity_iter) const; |
| 88 | + |
| 89 | + // non-virtual functions in this class |
| 90 | +protected: |
| 91 | + void print_add(const print_context & c, unsigned level, bool latex) const; |
| 92 | + void do_print(const print_context & c, unsigned level) const override; |
| 93 | + void do_print_latex(const print_latex & c, unsigned level) const; |
| 94 | + void do_print_python_repr(const print_python_repr & c, unsigned level) const override; |
| 95 | + |
| 96 | +public: |
| 97 | + ex combine_fractions() const; |
| 98 | +}; |
| 99 | + |
| 100 | +ex Power(const ex& base_, const ex& expo_); |
| 101 | + |
| 102 | +} // namespace GiNaC |
| 103 | + |
| 104 | +#endif // ndef __GINAC_ADD_H__ |
0 commit comments