3 * Interface to GiNaC's symbolic exponentiation (basis^exponent).
5 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef __GINAC_POWER_H__
23 #define __GINAC_POWER_H__
29 /** This class holds a two-component object, a basis and and exponent
30 * representing exponentiation. */
31 class power : public basic
37 // default constructor, destructor, copy constructor assignment operator and helpers
41 power(power const & other);
42 power const & operator=(power const & other);
44 void copy(power const & other);
45 void destroy(bool call_parent);
49 power(ex const & lh, ex const & rh);
50 power(ex const & lh, numeric const & rh);
52 // functions overriding virtual functions from bases classes
54 basic * duplicate() const;
55 void printraw(ostream & os) const;
56 void printtree(ostream & os, unsigned indent) const;
57 void print(ostream & os, unsigned upper_precedence=0) const;
58 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
59 bool info(unsigned inf) const;
61 ex & let_op(int const i);
62 int degree(symbol const & s) const;
63 int ldegree(symbol const & s) const;
64 ex coeff(symbol const & s, int const n=1) const;
65 ex eval(int level=0) const;
66 ex evalf(int level=0) const;
67 ex diff(symbol const & s) const;
68 ex series(symbol const & s, ex const & point, int order) const;
69 ex subs(lst const & ls, lst const & lr) const;
70 ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
71 ex simplify_ncmul(exvector const & v) const;
73 int compare_same_type(basic const & other) const;
74 unsigned return_type(void) const;
75 unsigned return_type_tinfo(void) const;
76 ex expand(unsigned options=0) const;
78 // new virtual functions which can be overridden by derived classes
81 // non-virtual functions in this class
83 ex expand_add(add const & a, int const n) const;
84 ex expand_add_2(add const & a) const;
85 ex expand_mul(mul const & m, numeric const & n) const;
86 //ex expand_commutative_3(ex const & basis, numeric const & exponent,
87 // unsigned options) const;
88 // ex expand_noncommutative(ex const & basis, numeric const & exponent, unsigned options) const;
95 static unsigned precedence;
100 extern const power some_power;
101 extern type_info const & typeid_power;
103 #define ex_to_power(X) static_cast<power const &>(*(X).bp)
107 /** Symbolic exponentiation. Returns a power-object as a new expression.
109 * @param b the basis expression
110 * @param e the exponent expression */
111 inline ex pow(ex const & b, ex const & e)
112 { return power(b,e); }
114 /** Square root expression. Returns a power-object with exponent 1/2 as a new
116 inline ex sqrt(ex const & a)
117 { return power(a,exHALF()); }
119 #endif // ndef __GINAC_POWER_H__