fmatvec  2.0.0
Fast Matrix/Vector Library
symbolic_function.h
1 #ifndef _FMATVEC_SYMBOLIC_FUNCTION_H_
2 #define _FMATVEC_SYMBOLIC_FUNCTION_H_
3 
4 #include "function.h"
5 #include "ast.h"
6 #include "symbolic.h"
7 
8 namespace fmatvec {
9 
10 // Replace in a fmatvec scalar, vector or matrix the AT with ATNew.
11 template<class MatVec, class NewAT>
12 struct ReplaceAT;
13 
14 template<class NewAT>
15 struct ReplaceAT<ErrorType, NewAT> {
16  using Type = ErrorType;
17 };
18 
19 template<class NewAT>
20 struct ReplaceAT<double, NewAT> {
21  using Type = NewAT;
22 };
23 
24 template<class Shape, class NewAT>
25 struct ReplaceAT<Vector<Shape, double>, NewAT> {
26  using Type = Vector<Shape, NewAT>;
27 };
28 
29 template<class Shape, class NewAT>
30 struct ReplaceAT<RowVector<Shape, double>, NewAT> {
32 };
33 
34 template<class MatType, class RowShape, class ColShape, class NewAT>
35 struct ReplaceAT<Matrix<MatType, RowShape, ColShape, double>, NewAT> {
37 };
38 
39 namespace {
40  template<class ATIndep>
41  struct Helper {
42  static void initIndep(ATIndep &x, int size) { x=ATIndep(); }
43  static int size1(const ATIndep &x) { return 1; }
44  static int size2(const ATIndep &x) { return 1; }
45  };
46 
47  template<class Shape, class ATIndep>
48  struct Helper<Vector<Shape, ATIndep>> {
49  static void initIndep(Vector<Shape, ATIndep> &x, int size) { x <<= Vector<Shape, ATIndep>(size, NONINIT); }
50  static int size1(const Vector<Shape, ATIndep> &x) { return x.size(); }
51  static int size2(const Vector<Shape, ATIndep> &x) { return 1; }
52  };
53 
54  template<class Type, class RowShape, class ColShape, class ATIndep>
55  struct Helper<Matrix<Type, RowShape, ColShape, ATIndep>> {
56  static int size1(const Matrix<Type, RowShape, ColShape, ATIndep> &x) { return x.rows(); }
57  static int size2(const Matrix<Type, RowShape, ColShape, ATIndep> &x) { return x.cols(); }
58  };
59 }
60 
61 template<typename Sig>
63 
64 #define RET Ret
65 #define ARG ATArg
66 #define TEMPLATE typename Ret, typename ATArg
67 #define PARDER
68 #define PARDERPARDER
69 #include "symbolic_function1_temp.h"
70 #undef RET
71 #undef ARG
72 #undef TEMPLATE
73 #undef PARDER
74 #undef PARDERPARDER
75 
76 #define RET Ret
77 #define ARG Vector<ArgShape, ATArg>
78 #define TEMPLATE typename Ret, typename ArgShape, typename ATArg
79 #define PARDER
80 //#define PARDERPARDER
81 #include "symbolic_function1_temp.h"
82 #undef RET
83 #undef ARG
84 #undef TEMPLATE
85 #undef PARDER
86 #undef PARDERPARDER
87 
88 #define RET RowVector<RetShape, ATRet>
89 #define ARG Vector<ArgShape, ATArg>
90 #define TEMPLATE typename RetShape, typename ATRet, typename ArgShape, typename ATArg
91 //#define PARDER
92 //#define PARDERPARDER
93 #include "symbolic_function1_temp.h"
94 #undef RET
95 #undef ARG
96 #undef TEMPLATE
97 #undef PARDER
98 #undef PARDERPARDER
99 
100 #define RET Matrix<Type, ColShape, RowShape, ATRet>
101 #define ARG Vector<ArgShape, ATArg>
102 #define TEMPLATE typename Type, typename ColShape, typename RowShape, typename ATRet, typename ArgShape, typename ATArg
103 //#define PARDER
104 //#define PARDERPARDER
105 #include "symbolic_function1_temp.h"
106 #undef RET
107 #undef ARG
108 #undef TEMPLATE
109 #undef PARDER
110 #undef PARDERPARDER
111 
112 #define RET Matrix<Rotation, Fixed<3>, Fixed<3>, ATRet>
113 #define ARG Vector<ArgShape, ATArg>
114 #define TEMPLATE typename ATRet, typename ArgShape, typename ATArg
115 #define PARDER
116 //#define PARDERPARDER
117 #include "symbolic_function1_temp.h"
118 #undef RET
119 #undef ARG
120 #undef TEMPLATE
121 #undef PARDER
122 #undef PARDERPARDER
123 
124 
125 
126 #define RET Ret
127 #define ARG1 ATArg1
128 #define ARG2 ATArg2
129 #define TEMPLATE typename Ret, typename ATArg1, typename ATArg2
130 #define PARDER1
131 #define PARDER2
132 #define PARDER1PARDER1
133 #define PARDER2PARDER2
134 #define PARDER1PARDER2
135 #include "symbolic_function2_temp.h"
136 #undef RET
137 #undef ARG1
138 #undef ARG2
139 #undef TEMPLATE
140 #undef PARDER1
141 #undef PARDER2
142 #undef PARDER1PARDER1
143 #undef PARDER2PARDER2
144 #undef PARDER1PARDER2
145 
146 #define RET Ret
147 #define ARG1 Vector<Shape, ATArg>
148 #define ARG2 ATArg
149 #define TEMPLATE typename Ret, typename Shape, typename ATArg
150 #define PARDER1
151 #define PARDER2
152 //#define PARDER1PARDER1
153 #define PARDER2PARDER2
154 #define PARDER1PARDER2
155 #include "symbolic_function2_temp.h"
156 #undef RET
157 #undef ARG1
158 #undef ARG2
159 #undef TEMPLATE
160 #undef PARDER1
161 #undef PARDER2
162 #undef PARDER1PARDER1
163 #undef PARDER2PARDER2
164 #undef PARDER1PARDER2
165 
166 #define RET Matrix<Rotation, Fixed<3>, Fixed<3>, ATRet>
167 #define ARG1 Vector<Shape, ATArg>
168 #define ARG2 ATArg
169 #define TEMPLATE typename ATRet, typename Shape, typename ATArg
170 #define PARDER1
171 #define PARDER2
172 //#define PARDER1PARDER1
173 #define PARDER2PARDER2
174 #define PARDER1PARDER2
175 #include "symbolic_function2_temp.h"
176 #undef RET
177 #undef ARG1
178 #undef ARG2
179 #undef TEMPLATE
180 #undef PARDER1
181 #undef PARDER2
182 #undef PARDER1PARDER1
183 #undef PARDER2PARDER2
184 #undef PARDER1PARDER2
185 
186 #define RET Ret
187 #define ARG1 ATArg
188 #define ARG2 Vector<Shape, ATArg>
189 #define TEMPLATE typename Ret, typename Shape, typename ATArg
190 #define PARDER1
191 #define PARDER2
192 #define PARDER1PARDER1
193 //#define PARDER2PARDER2
194 #define PARDER1PARDER2
195 #include "symbolic_function2_temp.h"
196 #undef RET
197 #undef ARG1
198 #undef ARG2
199 #undef TEMPLATE
200 #undef PARDER1
201 #undef PARDER2
202 #undef PARDER1PARDER1
203 #undef PARDER2PARDER2
204 #undef PARDER1PARDER2
205 
206 #define RET Matrix<Rotation, Fixed<3>, Fixed<3>, ATRet>
207 #define ARG1 ATArg
208 #define ARG2 Vector<Shape, ATArg>
209 #define TEMPLATE typename ATRet, typename Shape, typename ATArg
210 #define PARDER1
211 #define PARDER2
212 #define PARDER1PARDER1
213 //#define PARDER2PARDER2
214 #define PARDER1PARDER2
215 #include "symbolic_function2_temp.h"
216 #undef RET
217 #undef ARG1
218 #undef ARG2
219 #undef TEMPLATE
220 #undef PARDER1
221 #undef PARDER2
222 #undef PARDER1PARDER1
223 #undef PARDER2PARDER2
224 #undef PARDER1PARDER2
225 
226 #define RET Ret
227 #define ARG1 Vector<Shape1, ATArg>
228 #define ARG2 Vector<Shape2, ATArg>
229 #define TEMPLATE typename Ret, typename Shape1, typename Shape2, typename ATArg
230 #define PARDER1
231 #define PARDER2
232 //#define PARDER1PARDER1
233 //#define PARDER2PARDER2
234 //#define PARDER1PARDER2
235 #include "symbolic_function2_temp.h"
236 #undef RET
237 #undef ARG1
238 #undef ARG2
239 #undef TEMPLATE
240 #undef PARDER1
241 #undef PARDER2
242 #undef PARDER1PARDER1
243 #undef PARDER2PARDER2
244 #undef PARDER1PARDER2
245 
246 #define RET Matrix<Rotation, Fixed<3>, Fixed<3>, ATRet>
247 #define ARG1 Vector<Shape1, ATArg>
248 #define ARG2 Vector<Shape2, ATArg>
249 #define TEMPLATE typename ATRet, typename Shape1, typename Shape2, typename ATArg
250 #define PARDER1
251 #define PARDER2
252 //#define PARDER1PARDER1
253 //#define PARDER2PARDER2
254 //#define PARDER1PARDER2
255 #include "symbolic_function2_temp.h"
256 #undef RET
257 #undef ARG1
258 #undef ARG2
259 #undef TEMPLATE
260 #undef PARDER1
261 #undef PARDER2
262 #undef PARDER1PARDER1
263 #undef PARDER2PARDER2
264 #undef PARDER1PARDER2
265 
266 #define RET RowVector<RetShape, ATRet>
267 #define ARG1 Vector<Shape, ATArg>
268 #define ARG2 ATArg
269 #define TEMPLATE typename RetShape, typename ATRet, typename Shape, typename ATArg
270 //#define PARDER1
271 #define PARDER2
272 //#define PARDER1PARDER1
273 #define PARDER2PARDER2
274 //#define PARDER1PARDER2
275 #include "symbolic_function2_temp.h"
276 #undef RET
277 #undef ARG1
278 #undef ARG2
279 #undef TEMPLATE
280 #undef PARDER1
281 #undef PARDER2
282 #undef PARDER1PARDER1
283 #undef PARDER2PARDER2
284 #undef PARDER1PARDER2
285 
286 #define RET Matrix<Type, RowShape, ColShape, ATRet>
287 #define ARG1 Vector<Shape, ATArg>
288 #define ARG2 ATArg
289 #define TEMPLATE typename Type, typename RowShape, typename ColShape, typename ATRet, typename Shape, typename ATArg
290 //#define PARDER1
291 #define PARDER2
292 //#define PARDER1PARDER1
293 #define PARDER2PARDER2
294 //#define PARDER1PARDER2
295 #include "symbolic_function2_temp.h"
296 #undef RET
297 #undef ARG1
298 #undef ARG2
299 #undef TEMPLATE
300 #undef PARDER1
301 #undef PARDER2
302 #undef PARDER1PARDER1
303 #undef PARDER2PARDER2
304 #undef PARDER1PARDER2
305 
306 #define RET RowVector<RetShape, ATRet>
307 #define ARG1 ATArg
308 #define ARG2 Vector<Shape, ATArg>
309 #define TEMPLATE typename RetShape, typename ATRet, typename Shape, typename ATArg
310 #define PARDER1
311 //#define PARDER2
312 #define PARDER1PARDER1
313 //#define PARDER2PARDER2
314 //#define PARDER1PARDER2
315 #include "symbolic_function2_temp.h"
316 #undef RET
317 #undef ARG1
318 #undef ARG2
319 #undef TEMPLATE
320 #undef PARDER1
321 #undef PARDER2
322 #undef PARDER1PARDER1
323 #undef PARDER2PARDER2
324 #undef PARDER1PARDER2
325 
326 #define RET Matrix<Type, RowShape, ColShape, ATRet>
327 #define ARG1 ATArg
328 #define ARG2 Vector<Shape, ATArg>
329 #define TEMPLATE typename Type, typename RowShape, typename ColShape, typename ATRet, typename Shape, typename ATArg
330 #define PARDER1
331 //#define PARDER2
332 #define PARDER1PARDER1
333 //#define PARDER2PARDER2
334 //#define PARDER1PARDER2
335 #include "symbolic_function2_temp.h"
336 #undef RET
337 #undef ARG1
338 #undef ARG2
339 #undef TEMPLATE
340 #undef PARDER1
341 #undef PARDER2
342 #undef PARDER1PARDER1
343 #undef PARDER2PARDER2
344 #undef PARDER1PARDER2
345 
346 #define RET RowVector<RetShape, ATRet>
347 #define ARG1 Vector<Shape1, ATArg>
348 #define ARG2 Vector<Shape2, ATArg>
349 #define TEMPLATE typename RetShape, typename ATRet, typename Shape1, typename ATArg, typename Shape2
350 //#define PARDER1
351 //#define PARDER2
352 //#define PARDER1PARDER1
353 //#define PARDER2PARDER2
354 //#define PARDER1PARDER2
355 #include "symbolic_function2_temp.h"
356 #undef RET
357 #undef ARG1
358 #undef ARG2
359 #undef TEMPLATE
360 #undef PARDER1
361 #undef PARDER2
362 #undef PARDER1PARDER1
363 #undef PARDER2PARDER2
364 #undef PARDER1PARDER2
365 
366 #define RET Matrix<Type, RowShape, ColShape, ATRet>
367 #define ARG1 Vector<Shape1, ATArg>
368 #define ARG2 Vector<Shape2, ATArg>
369 #define TEMPLATE typename Type, typename RowShape, typename ColShape, typename ATRet, typename Shape1, typename ATArg, typename Shape2
370 //#define PARDER1
371 //#define PARDER2
372 //#define PARDER1PARDER1
373 //#define PARDER2PARDER2
374 //#define PARDER1PARDER2
375 #include "symbolic_function2_temp.h"
376 #undef RET
377 #undef ARG1
378 #undef ARG2
379 #undef TEMPLATE
380 #undef PARDER1
381 #undef PARDER2
382 #undef PARDER1PARDER1
383 #undef PARDER2PARDER2
384 #undef PARDER1PARDER2
385 
386 }
387 
388 #endif
389 
390 
391 
392 
393 
394 // 1: definition
395 // 2: value
396 // 3: parDer1
397 // 4: dirDer1
398 // 5: parDer2
399 // 6: dirDer2
400 // 7: parDer1ParDer1
401 // 8: parDer1DirDer1
402 // 9: dirDer1DirDer1
403 // 10: parDer2ParDer2
404 // 11: parDer2DirDer2
405 // 12: dirDer2DirDer2
406 // 13: parDer1ParDer2
407 // 14: parDer1DirDer2
408 // 15: dirDer2DirDer1
409 // 16: parDer2DirDer1
410 //
411 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
412 //
413 // sss s s s s s s s s s s s s s s s
414 // vss v v v v v v v v v v v v v v v
415 // rss r r r r r r r r r r r r r r r
416 // Mss M M M M M M M M M M M M M M M
417 // Rss R v v v v v v v v v v v v v v
418 // svv s r s r s E r s E r s E r s r
419 // vvv v M v M v E M v E M v E M v M
420 // rvv r E r E r E E r E E r E E r E
421 // Mvv M E M E M E E M E E M E E M E
422 // Rvv R M v M v E M v E M v E M v M
423 // ssv s s s r s s s s E r s r s s r
424 // vsv v v v M v v v v E M v M v v M
425 // rsv r r r E r r r r E E r E r r E
426 // Msv M M M E M M M M E E M E M M E
427 // Rsv R v v M v v v v E M v M v v M
428 // svs s r s s s E r s s s s r r s s
429 // vvs v M v v v E M v v v v M M v v
430 // rvs r E r r r E E r r r r E E r r
431 // Mvs M E M M M E E M M M M E E M M
432 // Rvs R M v v v E M v v v v M M v v
433 //
434 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
435 //
436 //
437 //
438 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
439 //
440 // aaa s s s s s s s s s s s s s s s
441 // vaa v v v v v v v v v v v v v v v
442 // raa r r r r r r r r r r r r r r r
443 // Maa M M M M M M M M M M M M M M M
444 // Raa R v v v v v v v v v v v v v v
445 //
446 // ava s r s s s E r s s s s r r s s
447 // vva v M v v v E M v v v v M M v v
448 // Rva R M v v v E M v v v v M M v v
449 //
450 // aav s s s r s s s s E r s r s s r
451 // vav v v v M v v v v E M v M v v M
452 // Rav R v v M v v v v E M v M v v M
453 //
454 // avv s r s r s E r s E r s E r s r
455 // vvv v M v M v E M v E M v E M v M
456 // Rvv R M v M v E M v E M v E M v M
457 //
458 // rva r E r r r E E r r r r E E r r
459 // Mva M E M M M E E M M M M E E M M
460 //
461 // rav r r r E r r r r E E r E r r E
462 // Mav M M M E M M M M E E M E M M E
463 //
464 // rvv r E r E r E E r E E r E E r E
465 // Mvv M E M E M E E M E E M E E M E
466 //
467 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
Definition: fmatvec.h:50
Definition: function.h:13
Definition: fmatvec.h:47
Namespace fmatvec.
Definition: _memory.cc:28
Definition: symbolic_function.h:62
Definition: symbolic_function.h:12