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__
25 #include <ginac/basic.h>
31 /** This class holds a two-component object, a basis and and exponent
32 * representing exponentiation. */
33 class power : public basic
39 // default constructor, destructor, copy constructor assignment operator and helpers
43 power(power const & other);
44 power const & operator=(power const & other);
46 void copy(power const & other);
47 void destroy(bool call_parent);
51 power(ex const & lh, ex const & rh);
52 power(ex const & lh, numeric const & rh);
54 // functions overriding virtual functions from bases classes
56 basic * duplicate() const;
57 void printraw(ostream & os) const;
58 void printtree(ostream & os, unsigned indent) const;
59 void print(ostream & os, unsigned upper_precedence=0) const;
60 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
61 bool info(unsigned inf) const;
63 ex & let_op(int const i);
64 int degree(symbol const & s) const;
65 int ldegree(symbol const & s) const;
66 ex coeff(symbol const & s, int const n=1) const;
67 ex eval(int level=0) const;
68 ex evalf(int level=0) const;
69 ex diff(symbol const & s) const;
70 ex series(symbol const & s, ex const & point, int order) const;
71 ex subs(lst const & ls, lst const & lr) const;
72 ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
73 ex simplify_ncmul(exvector const & v) const;
75 int compare_same_type(basic const & other) const;
76 unsigned return_type(void) const;
77 unsigned return_type_tinfo(void) const;
78 ex expand(unsigned options=0) const;
80 // new virtual functions which can be overridden by derived classes
83 // non-virtual functions in this class
85 ex expand_add(add const & a, int const n) const;
86 ex expand_add_2(add const & a) const;
87 ex expand_mul(mul const & m, numeric const & n) const;
88 //ex expand_commutative_3(ex const & basis, numeric const & exponent,
89 // unsigned options) const;
90 // ex expand_noncommutative(ex const & basis, numeric const & exponent, unsigned options) const;
97 static unsigned precedence;
102 extern const power some_power;
103 extern type_info const & typeid_power;
105 #define ex_to_power(X) static_cast<power const &>(*(X).bp)
109 /** Symbolic exponentiation. Returns a power-object as a new expression.
111 * @param b the basis expression
112 * @param e the exponent expression */
113 inline ex pow(ex const & b, ex const & e)
114 { return power(b,e); }
116 /** Square root expression. Returns a power-object with exponent 1/2 as a new
118 inline ex sqrt(ex const & a)
119 { return power(a,exHALF()); }
121 #endif // ndef __GINAC_POWER_H__