]> www.ginac.de Git - ginac.git/blob - ginac/fderivative.h
[bugfix]: parser::parse_unary_expr() parses '-a-b' correctly now.
[ginac.git] / ginac / fderivative.h
1 /** @file fderivative.h
2  *
3  *  Interface to abstract derivatives of functions. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef __GINAC_FDERIVATIVE_H__
24 #define __GINAC_FDERIVATIVE_H__
25
26 #include <set>
27
28 #include "function.h"
29
30 namespace GiNaC {
31
32
33 typedef std::multiset<unsigned> paramset;
34
35 /** This class represents the (abstract) derivative of a symbolic function.
36  *  It is used to represent the derivatives of functions that do not have
37  *  a derivative or series expansion procedure defined. */
38 class fderivative : public function
39 {
40         GINAC_DECLARE_REGISTERED_CLASS(fderivative, function)
41
42         // other constructors
43 public:
44         /** Construct derivative with respect to one parameter.
45          *
46          *  @param ser Serial number of function
47          *  @param param Number of parameter with respect to which to take the derivative
48          *  @param args Arguments of derivative function */
49         fderivative(unsigned ser, unsigned param, const exvector & args);
50
51         /** Construct derivative with respect to multiple parameters.
52          *
53          *  @param ser Serial number of function
54          *  @param params Set of numbers of parameters with respect to which to take the derivative
55          *  @param args Arguments of derivative function */
56         fderivative(unsigned ser, const paramset & params, const exvector & args);
57
58         // internal constructors
59         fderivative(unsigned ser, const paramset & params, std::auto_ptr<exvector> vp);
60
61         // functions overriding virtual functions from base classes
62 public:
63         void print(const print_context & c, unsigned level = 0) const;
64         ex eval(int level = 0) const;
65         ex evalf(int level = 0) const;
66         ex series(const relational & r, int order, unsigned options = 0) const;
67         ex thiscontainer(const exvector & v) const;
68         ex thiscontainer(std::auto_ptr<exvector> vp) const;
69 protected:
70         ex derivative(const symbol & s) const;
71         bool is_equal_same_type(const basic & other) const;
72         bool match_same_type(const basic & other) const;
73
74         // non-virtual functions in this class
75 protected:
76         void do_print(const print_context & c, unsigned level) const;
77         void do_print_csrc(const print_csrc & c, unsigned level) const;
78         void do_print_tree(const print_tree & c, unsigned level) const;
79
80         // member variables
81 protected:
82         paramset parameter_set; /**< Set of parameter numbers with respect to which to take the derivative */
83 };
84
85 } // namespace GiNaC
86
87 #endif // ndef __GINAC_DERIVATIVE_H__