]> www.ginac.de Git - ginac.git/blob - ginac/fderivative.h
unit_matrix() uses a heap-allocated matrix
[ginac.git] / ginac / fderivative.h
1 /** @file fderivative.h
2  *
3  *  Interface to abstract derivatives of functions. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2003 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_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, exvector * vp); // vp will be deleted
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 thisexprseq(const exvector & v) const;
68         ex thisexprseq(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         // member variables
75 protected:
76         paramset parameter_set; /**< Set of parameter numbers with respect to which to take the derivative */
77 };
78
79 // utility functions
80
81 /** Specialization of is_exactly_a<T>(obj) for derivatives. */
82 template<> inline bool is_exactly_a<fderivative>(const basic & obj)
83 {
84         return obj.tinfo()==TINFO_fderivative;
85 }
86
87 } // namespace GiNaC
88
89 #endif // ndef __GINAC_DERIVATIVE_H__