1 /** @file mul.h 2 * 3 * Interface to GiNaC's products of expressions. */ 4 5 /* 6 * GiNaC Copyright (C) 1999-2022 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_MUL_H 24 #define GINAC_MUL_H 25 26 #include "expairseq.h" 27 28 namespace GiNaC { 29 30 /** Product of expressions. */ 31 class mul : public expairseq 32 { 33 GINAC_DECLARE_REGISTERED_CLASS(mul, expairseq) 34 35 friend class add; 36 friend class ncmul; 37 friend class power; 38 39 // other constructors 40 public: 41 mul(const ex & lh, const ex & rh); 42 mul(const exvector & v); 43 mul(const epvector & v); 44 mul(const epvector & v, const ex & oc, bool do_index_renaming = false); 45 mul(epvector && vp); 46 mul(epvector && vp, const ex & oc, bool do_index_renaming = false); 47 mul(const ex & lh, const ex & mh, const ex & rh); 48 49 // functions overriding virtual functions from base classes 50 public: precedence()51 unsigned precedence() const override {return 50;} 52 bool info(unsigned inf) const override; 53 bool is_polynomial(const ex & var) const override; 54 int degree(const ex & s) const override; 55 int ldegree(const ex & s) const override; 56 ex coeff(const ex & s, int n = 1) const override; 57 bool has(const ex & other, unsigned options = 0) const override; 58 ex eval() const override; 59 ex evalf() const override; 60 ex real_part() const override; 61 ex imag_part() const override; 62 ex evalm() const override; 63 ex series(const relational & s, int order, unsigned options = 0) const override; 64 ex normal(exmap & repl, exmap & rev_lookup, lst & modifier) const override; 65 numeric integer_content() const override; 66 ex smod(const numeric &xi) const override; 67 numeric max_coefficient() const override; 68 exvector get_free_indices() const override; 69 ex conjugate() const override; 70 protected: 71 ex derivative(const symbol & s) const override; 72 ex eval_ncmul(const exvector & v) const override; 73 unsigned return_type() const override; 74 return_type_t return_type_tinfo() const override; 75 ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const override; 76 ex thisexpairseq(epvector && vp, const ex & oc, bool do_index_renaming = false) const override; 77 expair split_ex_to_pair(const ex & e) const override; 78 expair combine_ex_with_coeff_to_pair(const ex & e, const ex & c) const override; 79 expair combine_pair_with_coeff_to_pair(const expair & p, const ex & c) const override; 80 ex recombine_pair_to_ex(const expair & p) const override; 81 bool expair_needs_further_processing(epp it) override; 82 ex default_overall_coeff() const override; 83 void combine_overall_coeff(const ex & c) override; 84 void combine_overall_coeff(const ex & c1, const ex & c2) override; 85 bool can_make_flat(const expair & p) const override; 86 ex expand(unsigned options=0) const override; 87 88 // new virtual functions which can be overridden by derived classes 89 // none 90 91 // non-virtual functions in this class 92 public: 93 ex algebraic_subs_mul(const exmap & m, unsigned options) const; 94 protected: 95 void find_real_imag(ex&, ex&) const; 96 void print_overall_coeff(const print_context & c, const char *mul_sym) const; 97 void do_print(const print_context & c, unsigned level) const; 98 void do_print_latex(const print_latex & c, unsigned level) const; 99 void do_print_csrc(const print_csrc & c, unsigned level) const; 100 void do_print_python_repr(const print_python_repr & c, unsigned level) const; 101 static bool can_be_further_expanded(const ex & e); 102 epvector expandchildren(unsigned options) const; 103 }; 104 GINAC_DECLARE_UNARCHIVER(mul); 105 106 } // namespace GiNaC 107 108 #endif // ndef GINAC_MUL_H 109