]> www.ginac.de Git - ginac.git/blob - ginac/power.h
building in separate directory didn't work
[ginac.git] / ginac / power.h
1 /** @file power.h
2  *
3  *  Interface to GiNaC's symbolic exponentiation (basis^exponent). */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #ifndef __GINAC_POWER_H__
24 #define __GINAC_POWER_H__
25
26 #include "basic.h"
27 #include "ex.h"
28
29 #ifndef NO_NAMESPACE_GINAC
30 namespace GiNaC {
31 #endif // ndef NO_NAMESPACE_GINAC
32
33 class numeric;
34 class add;
35
36 /** This class holds a two-component object, a basis and and exponent
37  *  representing exponentiation. */
38 class power : public basic
39 {
40         GINAC_DECLARE_REGISTERED_CLASS(power, basic)
41
42         friend class mul;
43
44 // member functions
45
46         // other constructors
47 public:
48         power(const ex & lh, const ex & rh);
49         power(const ex & lh, const numeric & rh);
50
51         // functions overriding virtual functions from bases classes
52 public:
53         void print(std::ostream & os, unsigned upper_precedence = 0) const;
54         void printraw(std::ostream & os) const;
55         void printtree(std::ostream & os, unsigned indent) const;
56         void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence = 0) const;
57         bool info(unsigned inf) const;
58         unsigned nops() const;
59         ex & let_op(int i);
60         int degree(const symbol & s) const;
61         int ldegree(const symbol & s) const;
62         ex coeff(const symbol & s, int n = 1) const;
63         ex eval(int level=0) const;
64         ex evalf(int level=0) const;
65         ex series(const relational & s, int order, unsigned options = 0) const;
66         ex subs(const lst & ls, const lst & lr) const;
67         ex normal(lst &sym_lst, lst &repl_lst, int level = 0) const;
68         ex to_rational(lst &repl_lst) const;
69         ex simplify_ncmul(const exvector & v) const;
70 protected:
71         ex derivative(const symbol & s) const;
72         unsigned return_type(void) const;
73         unsigned return_type_tinfo(void) const;
74         ex expand(unsigned options = 0) const;
75         
76         // new virtual functions which can be overridden by derived classes
77         // none
78         
79         // non-virtual functions in this class
80 protected:
81         ex expand_add(const add & a, int n) const;
82         ex expand_add_2(const add & a) const;
83         ex expand_mul(const mul & m, const numeric & n) const;
84         //ex expand_commutative_3(const ex & basis, const numeric & exponent,
85         //                        unsigned options) const;
86         //ex expand_noncommutative(const ex & basis, const numeric & exponent, unsigned options) const;
87
88 // member variables
89
90 protected:
91         ex basis;
92         ex exponent;
93         static unsigned precedence;
94 };
95
96 // utility functions
97 inline const power &ex_to_power(const ex &e)
98 {
99         return static_cast<const power &>(*e.bp);
100 }
101
102 // wrapper functions
103
104 /** Symbolic exponentiation.  Returns a power-object as a new expression.
105  *
106  *  @param b the basis expression
107  *  @param e the exponent expression */
108 inline ex pow(const ex & b, const ex & e)
109 { return power(b,e); }
110
111 /** Square root expression.  Returns a power-object with exponent 1/2 as a new
112  *  expression.  */
113 ex sqrt(const ex & a);
114
115 #ifndef NO_NAMESPACE_GINAC
116 } // namespace GiNaC
117 #endif // ndef NO_NAMESPACE_GINAC
118
119 #endif // ndef __GINAC_POWER_H__