3 * Interface to abstract class function (new function concept).
5 * This file was generated automatically by function.pl.
6 * Please do not modify it directly, edit the perl script instead!
7 * function.pl options: $maxargs=10 */
20 // the following lines have been generated for max. 10 parameters
21 #define DECLARE_FUNCTION_1P(NAME) \
22 extern unsigned function_index_##NAME; \
23 inline function NAME(ex const & p1) { \
24 return function(function_index_##NAME, p1); \
27 #define DECLARE_FUNCTION_2P(NAME) \
28 extern unsigned function_index_##NAME; \
29 inline function NAME(ex const & p1, ex const & p2) { \
30 return function(function_index_##NAME, p1, p2); \
33 #define DECLARE_FUNCTION_3P(NAME) \
34 extern unsigned function_index_##NAME; \
35 inline function NAME(ex const & p1, ex const & p2, ex const & p3) { \
36 return function(function_index_##NAME, p1, p2, p3); \
39 #define DECLARE_FUNCTION_4P(NAME) \
40 extern unsigned function_index_##NAME; \
41 inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4) { \
42 return function(function_index_##NAME, p1, p2, p3, p4); \
45 #define DECLARE_FUNCTION_5P(NAME) \
46 extern unsigned function_index_##NAME; \
47 inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5) { \
48 return function(function_index_##NAME, p1, p2, p3, p4, p5); \
51 #define DECLARE_FUNCTION_6P(NAME) \
52 extern unsigned function_index_##NAME; \
53 inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6) { \
54 return function(function_index_##NAME, p1, p2, p3, p4, p5, p6); \
57 #define DECLARE_FUNCTION_7P(NAME) \
58 extern unsigned function_index_##NAME; \
59 inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7) { \
60 return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7); \
63 #define DECLARE_FUNCTION_8P(NAME) \
64 extern unsigned function_index_##NAME; \
65 inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7, ex const & p8) { \
66 return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8); \
69 #define DECLARE_FUNCTION_9P(NAME) \
70 extern unsigned function_index_##NAME; \
71 inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7, ex const & p8, ex const & p9) { \
72 return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8, p9); \
75 #define DECLARE_FUNCTION_10P(NAME) \
76 extern unsigned function_index_##NAME; \
77 inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7, ex const & p8, ex const & p9, ex const & p10) { \
78 return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
82 // end of generated lines
84 #define REGISTER_FUNCTION(NAME,E,EF,D,S) \
85 unsigned function_index_##NAME=function::register_new(#NAME,E,EF,D,S);
87 #define BEGIN_TYPECHECK \
88 bool automatic_typecheck=true;
90 #define TYPECHECK(VAR,TYPE) \
91 if (!is_ex_exactly_of_type(VAR,TYPE)) { \
92 automatic_typecheck=false; \
95 #define TYPECHECK_INTEGER(VAR) \
96 if (!(VAR).info(info_flags::integer)) { \
97 automatic_typecheck=false; \
100 #define END_TYPECHECK(RV) \
102 if (!automatic_typecheck) { \
106 typedef ex (* eval_funcp)();
107 typedef ex (* evalf_funcp)();
108 typedef ex (* diff_funcp)();
109 typedef ex (* series_funcp)();
111 // the following lines have been generated for max. 10 parameters
112 typedef ex (* eval_funcp_1)(ex const &);
113 typedef ex (* eval_funcp_2)(ex const &, ex const &);
114 typedef ex (* eval_funcp_3)(ex const &, ex const &, ex const &);
115 typedef ex (* eval_funcp_4)(ex const &, ex const &, ex const &, ex const &);
116 typedef ex (* eval_funcp_5)(ex const &, ex const &, ex const &, ex const &, ex const &);
117 typedef ex (* eval_funcp_6)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
118 typedef ex (* eval_funcp_7)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
119 typedef ex (* eval_funcp_8)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
120 typedef ex (* eval_funcp_9)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
121 typedef ex (* eval_funcp_10)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
123 typedef ex (* evalf_funcp_1)(ex const &);
124 typedef ex (* evalf_funcp_2)(ex const &, ex const &);
125 typedef ex (* evalf_funcp_3)(ex const &, ex const &, ex const &);
126 typedef ex (* evalf_funcp_4)(ex const &, ex const &, ex const &, ex const &);
127 typedef ex (* evalf_funcp_5)(ex const &, ex const &, ex const &, ex const &, ex const &);
128 typedef ex (* evalf_funcp_6)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
129 typedef ex (* evalf_funcp_7)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
130 typedef ex (* evalf_funcp_8)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
131 typedef ex (* evalf_funcp_9)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
132 typedef ex (* evalf_funcp_10)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &);
134 typedef ex (* diff_funcp_1)(ex const &, unsigned);
135 typedef ex (* diff_funcp_2)(ex const &, ex const &, unsigned);
136 typedef ex (* diff_funcp_3)(ex const &, ex const &, ex const &, unsigned);
137 typedef ex (* diff_funcp_4)(ex const &, ex const &, ex const &, ex const &, unsigned);
138 typedef ex (* diff_funcp_5)(ex const &, ex const &, ex const &, ex const &, ex const &, unsigned);
139 typedef ex (* diff_funcp_6)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, unsigned);
140 typedef ex (* diff_funcp_7)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, unsigned);
141 typedef ex (* diff_funcp_8)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, unsigned);
142 typedef ex (* diff_funcp_9)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, unsigned);
143 typedef ex (* diff_funcp_10)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, unsigned);
145 typedef ex (* series_funcp_1)(ex const &, symbol const &, ex const &, int);
146 typedef ex (* series_funcp_2)(ex const &, ex const &, symbol const &, ex const &, int);
147 typedef ex (* series_funcp_3)(ex const &, ex const &, ex const &, symbol const &, ex const &, int);
148 typedef ex (* series_funcp_4)(ex const &, ex const &, ex const &, ex const &, symbol const &, ex const &, int);
149 typedef ex (* series_funcp_5)(ex const &, ex const &, ex const &, ex const &, ex const &, symbol const &, ex const &, int);
150 typedef ex (* series_funcp_6)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, symbol const &, ex const &, int);
151 typedef ex (* series_funcp_7)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, symbol const &, ex const &, int);
152 typedef ex (* series_funcp_8)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, symbol const &, ex const &, int);
153 typedef ex (* series_funcp_9)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, symbol const &, ex const &, int);
154 typedef ex (* series_funcp_10)(ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, ex const &, symbol const &, ex const &, int);
156 // end of generated lines
158 struct registered_function_info {
168 /** The class function is used to implement builtin functions like sin, cos...
169 and user defined functions */
170 class function : public exprseq
172 friend void ginsh_get_ginac_functions(void);
176 // default constructor, destructor, copy constructor assignment operator and helpers
180 function(function const & other);
181 function const & operator=(function const & other);
183 void copy(function const & other);
184 void destroy(bool call_parent);
186 // other constructors
188 function(unsigned ser);
189 // the following lines have been generated for max. 10 parameters
190 function(unsigned ser, ex const & param1);
191 function(unsigned ser, ex const & param1, ex const & param2);
192 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3);
193 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3, ex const & param4);
194 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3, ex const & param4, ex const & param5);
195 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3, ex const & param4, ex const & param5, ex const & param6);
196 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3, ex const & param4, ex const & param5, ex const & param6, ex const & param7);
197 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3, ex const & param4, ex const & param5, ex const & param6, ex const & param7, ex const & param8);
198 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3, ex const & param4, ex const & param5, ex const & param6, ex const & param7, ex const & param8, ex const & param9);
199 function(unsigned ser, ex const & param1, ex const & param2, ex const & param3, ex const & param4, ex const & param5, ex const & param6, ex const & param7, ex const & param8, ex const & param9, ex const & param10);
201 // end of generated lines
202 function(unsigned ser, exprseq const & es);
203 function(unsigned ser, exvector const & v, bool discardable=0);
204 function(unsigned ser, exvector * vp); // vp will be deleted
206 // functions overriding virtual functions from bases classes
208 basic * duplicate() const;
209 void printraw(ostream & os) const;
210 void print(ostream & os, unsigned upper_precedence=0) const;
211 void printtree(ostream & os, unsigned indent) const;
212 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
213 ex expand(unsigned options=0) const;
214 ex eval(int level=0) const;
215 ex evalf(int level=0) const;
216 ex diff(symbol const & s) const;
217 ex series(symbol const & s, ex const & point, int order) const;
218 ex thisexprseq(exvector const & v) const;
219 ex thisexprseq(exvector * vp) const;
221 int compare_same_type(basic const & other) const;
222 bool is_equal_same_type(basic const & other) const;
223 unsigned return_type(void) const;
224 unsigned return_type_tinfo(void) const;
226 // new virtual functions which can be overridden by derived classes
229 // non-virtual functions in this class
231 ex pdiff(unsigned diff_param) const; // partial differentiation
232 static vector<registered_function_info> & registered_functions(void);
234 // the following lines have been generated for max. 10 parameters
235 static unsigned register_new(char const * nm, eval_funcp_1 e,
236 evalf_funcp_1 ef=0, diff_funcp_1 d=0, series_funcp_1 s=0);
237 static unsigned register_new(char const * nm, eval_funcp_2 e,
238 evalf_funcp_2 ef=0, diff_funcp_2 d=0, series_funcp_2 s=0);
239 static unsigned register_new(char const * nm, eval_funcp_3 e,
240 evalf_funcp_3 ef=0, diff_funcp_3 d=0, series_funcp_3 s=0);
241 static unsigned register_new(char const * nm, eval_funcp_4 e,
242 evalf_funcp_4 ef=0, diff_funcp_4 d=0, series_funcp_4 s=0);
243 static unsigned register_new(char const * nm, eval_funcp_5 e,
244 evalf_funcp_5 ef=0, diff_funcp_5 d=0, series_funcp_5 s=0);
245 static unsigned register_new(char const * nm, eval_funcp_6 e,
246 evalf_funcp_6 ef=0, diff_funcp_6 d=0, series_funcp_6 s=0);
247 static unsigned register_new(char const * nm, eval_funcp_7 e,
248 evalf_funcp_7 ef=0, diff_funcp_7 d=0, series_funcp_7 s=0);
249 static unsigned register_new(char const * nm, eval_funcp_8 e,
250 evalf_funcp_8 ef=0, diff_funcp_8 d=0, series_funcp_8 s=0);
251 static unsigned register_new(char const * nm, eval_funcp_9 e,
252 evalf_funcp_9 ef=0, diff_funcp_9 d=0, series_funcp_9 s=0);
253 static unsigned register_new(char const * nm, eval_funcp_10 e,
254 evalf_funcp_10 ef=0, diff_funcp_10 d=0, series_funcp_10 s=0);
256 // end of generated lines
257 unsigned getserial(void) const {return serial;}
267 #define is_ex_the_function(OBJ, FUNCNAME) \
268 (is_ex_exactly_of_type(OBJ, function) && static_cast<function *>(OBJ.bp)->getserial() == function_index_##FUNCNAME)
272 extern const function some_function;
273 extern type_info const & typeid_function;
275 #endif // ndef _FUNCTION_H_