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