3 * Interface to GiNaC's symbolic exponentiation (basis^exponent). */
6 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
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.
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.
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
23 #ifndef __GINAC_POWER_H__
24 #define __GINAC_POWER_H__
26 #include <ginac/basic.h>
29 #ifndef NO_GINAC_NAMESPACE
31 #endif // ndef NO_GINAC_NAMESPACE
36 /** This class holds a two-component object, a basis and and exponent
37 * representing exponentiation. */
38 class power : public basic
40 GINAC_DECLARE_REGISTERED_CLASS(power, basic)
46 // default constructor, destructor, copy constructor assignment operator and helpers
50 power(power const & other);
51 power const & operator=(power const & other);
53 void copy(power const & other);
54 void destroy(bool call_parent);
58 power(ex const & lh, ex const & rh);
59 power(ex const & lh, numeric const & rh);
61 // functions overriding virtual functions from bases classes
63 basic * duplicate() const;
64 void print(ostream & os, unsigned upper_precedence=0) const;
65 void printraw(ostream & os) const;
66 void printtree(ostream & os, unsigned indent) const;
67 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
68 bool info(unsigned inf) const;
69 unsigned nops() const;
70 ex & let_op(int const i);
71 int degree(symbol const & s) const;
72 int ldegree(symbol const & s) const;
73 ex coeff(symbol const & s, int const n=1) const;
74 ex eval(int level=0) const;
75 ex evalf(int level=0) const;
76 ex diff(symbol const & s) const;
77 ex series(symbol const & s, ex const & point, int order) const;
78 ex subs(lst const & ls, lst const & lr) const;
79 ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
80 ex simplify_ncmul(exvector const & v) const;
82 int compare_same_type(basic const & other) const;
83 unsigned return_type(void) const;
84 unsigned return_type_tinfo(void) const;
85 ex expand(unsigned options=0) const;
87 // new virtual functions which can be overridden by derived classes
90 // non-virtual functions in this class
92 ex expand_add(add const & a, int const n) const;
93 ex expand_add_2(add const & a) const;
94 ex expand_mul(mul const & m, numeric const & n) const;
95 //ex expand_commutative_3(ex const & basis, numeric const & exponent,
96 // unsigned options) const;
97 // ex expand_noncommutative(ex const & basis, numeric const & exponent, unsigned options) const;
104 static unsigned precedence;
109 extern const power some_power;
110 extern type_info const & typeid_power;
113 inline const power &ex_to_power(const ex &e)
115 return static_cast<const power &>(*e.bp);
120 /** Symbolic exponentiation. Returns a power-object as a new expression.
122 * @param b the basis expression
123 * @param e the exponent expression */
124 inline ex pow(ex const & b, ex const & e)
125 { return power(b,e); }
127 /** Square root expression. Returns a power-object with exponent 1/2 as a new
129 ex sqrt(ex const & a);
131 #ifndef NO_GINAC_NAMESPACE
133 #endif // ndef NO_GINAC_NAMESPACE
135 #endif // ndef __GINAC_POWER_H__