3 * Interface to GiNaC's symbolic exponentiation (basis^exponent). */
12 /** This class holds a two-component object, a basis and and exponent
13 * representing exponentiation. */
14 class power : public basic
20 // default constructor, destructor, copy constructor assignment operator and helpers
24 power(power const & other);
25 power const & operator=(power const & other);
27 void copy(power const & other);
28 void destroy(bool call_parent);
32 power(ex const & lh, ex const & rh);
33 power(ex const & lh, numeric const & rh);
35 // functions overriding virtual functions from bases classes
37 basic * duplicate() const;
38 void printraw(ostream & os) const;
39 void printtree(ostream & os, unsigned indent) const;
40 void print(ostream & os, unsigned upper_precedence=0) const;
41 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
42 bool info(unsigned inf) const;
44 ex & let_op(int const i);
45 int degree(symbol const & s) const;
46 int ldegree(symbol const & s) const;
47 ex coeff(symbol const & s, int const n=1) const;
48 ex eval(int level=0) const;
49 ex evalf(int level=0) const;
50 ex diff(symbol const & s) const;
51 ex series(symbol const & s, ex const & point, int order) const;
52 ex subs(lst const & ls, lst const & lr) const;
53 ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
54 ex simplify_ncmul(exvector const & v) const;
56 int compare_same_type(basic const & other) const;
57 unsigned return_type(void) const;
58 unsigned return_type_tinfo(void) const;
59 ex expand(unsigned options=0) const;
61 // new virtual functions which can be overridden by derived classes
64 // non-virtual functions in this class
66 ex expand_add(add const & a, int const n) const;
67 ex expand_add_2(add const & a) const;
68 ex expand_mul(mul const & m, numeric const & n) const;
69 //ex expand_commutative_3(ex const & basis, numeric const & exponent,
70 // unsigned options) const;
71 // ex expand_noncommutative(ex const & basis, numeric const & exponent, unsigned options) const;
78 static unsigned precedence;
83 extern const power some_power;
84 extern type_info const & typeid_power;
86 #define ex_to_power(X) static_cast<power const &>(*(X).bp)
90 /** Symbolic exponentiation. Returns a power-object as a new expression.
92 * @param b the basis expression
93 * @param e the exponent expression */
94 inline ex pow(ex const & b, ex const & e)
95 { return power(b,e); }
97 /** Square root expression. Returns a power-object with exponent 1/2 as a new
99 inline ex sqrt(ex const & a)
100 { return power(a,exHALF()); }
102 #endif // ndef _POWER_H_