]> www.ginac.de Git - ginac.git/blob - ginac/power.h
- switched to automake build environment
[ginac.git] / ginac / power.h
1 /** @file power.h
2  *
3  *  Interface to GiNaC's symbolic exponentiation (basis^exponent). */
4
5 #ifndef _POWER_H_
6 #define _POWER_H_
7
8 class power;
9 class numeric;
10 class add;
11
12 /** This class holds a two-component object, a basis and and exponent
13  *  representing exponentiation. */
14 class power : public basic
15 {
16     friend class mul;
17
18 // member functions
19
20     // default constructor, destructor, copy constructor assignment operator and helpers
21 public:
22     power();
23     ~power();
24     power(power const & other);
25     power const & operator=(power const & other);
26 protected:
27     void copy(power const & other);
28     void destroy(bool call_parent);
29
30     // other constructors
31 public:
32     power(ex const & lh, ex const & rh);
33     power(ex const & lh, numeric const & rh);
34
35     // functions overriding virtual functions from bases classes
36 public:
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;
43     int nops() 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;
55 protected:
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;
60     
61     // new virtual functions which can be overridden by derived classes
62     // none
63     
64     // non-virtual functions in this class
65 protected:
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;
72
73 // member variables
74
75 protected:
76     ex basis;
77     ex exponent;
78     static unsigned precedence;
79 };
80
81 // global constants
82
83 extern const power some_power;
84 extern type_info const & typeid_power;
85
86 #define ex_to_power(X) static_cast<power const &>(*(X).bp)
87
88 // wrapper functions
89
90 /** Symbolic exponentiation.  Returns a power-object as a new expression.
91  *
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); }
96
97 /** Square root expression.  Returns a power-object with exponent 1/2 as a new
98  *  expression.  */
99 inline ex sqrt(ex const & a)
100 { return power(a,exHALF()); }
101
102 #endif // ndef _POWER_H_
103