1 | /* $Id: prototype_op.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ |
---|
2 | # ifndef CPPAD_PROTOTYPE_OP_INCLUDED |
---|
3 | # define CPPAD_PROTOTYPE_OP_INCLUDED |
---|
4 | |
---|
5 | /* -------------------------------------------------------------------------- |
---|
6 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell |
---|
7 | |
---|
8 | CppAD is distributed under multiple licenses. This distribution is under |
---|
9 | the terms of the |
---|
10 | Eclipse Public License Version 1.0. |
---|
11 | |
---|
12 | A copy of this license is included in the COPYING file of this distribution. |
---|
13 | Please visit http://www.coin-or.org/CppAD/ for information on other licenses. |
---|
14 | -------------------------------------------------------------------------- */ |
---|
15 | |
---|
16 | |
---|
17 | namespace CppAD { // BEGIN_CPPAD_NAMESPACE |
---|
18 | /*! |
---|
19 | \file prototype_op.hpp |
---|
20 | Documentation for generic cases (these generic cases are never used). |
---|
21 | */ |
---|
22 | |
---|
23 | // ==================== Unary operators with one result ==================== |
---|
24 | |
---|
25 | |
---|
26 | /*! |
---|
27 | Prototype for forward mode unary operator with one result (not used). |
---|
28 | |
---|
29 | \tparam Base |
---|
30 | base type for the operator; i.e., this operation was recorded |
---|
31 | using AD< \a Base > and computations by this routine are done using type |
---|
32 | \a Base. |
---|
33 | |
---|
34 | \param p |
---|
35 | lowest order of the Taylor coefficient that we are computing. |
---|
36 | |
---|
37 | \param q |
---|
38 | highest order of the Taylor coefficient that we are computing. |
---|
39 | |
---|
40 | \param i_z |
---|
41 | variable index corresponding to the result for this operation; |
---|
42 | i.e. the row index in \a taylor corresponding to z. |
---|
43 | |
---|
44 | \param i_x |
---|
45 | variable index corresponding to the argument for this operator; |
---|
46 | i.e. the row index in \a taylor corresponding to x. |
---|
47 | |
---|
48 | \param cap_order |
---|
49 | maximum number of orders that will fit in the \c taylor array. |
---|
50 | |
---|
51 | \param taylor |
---|
52 | \b Input: <code>taylor [ i_x * cap_order + k ]</code>, |
---|
53 | for k = 0 , ... , q, |
---|
54 | is the k-th order Taylor coefficient corresponding to x. |
---|
55 | \n |
---|
56 | \b Input: <code>taylor [ i_z * cap_order + k ]</code>, |
---|
57 | for k = 0 , ... , p-1, |
---|
58 | is the k-th order Taylor coefficient corresponding to z. |
---|
59 | \n |
---|
60 | \b Output: <code>taylor [ i_z * cap_order + k ]</code>, |
---|
61 | for k = p , ... , q, |
---|
62 | is the k-th order Taylor coefficient corresponding to z. |
---|
63 | |
---|
64 | \par Checked Assertions |
---|
65 | \li NumArg(op) == 1 |
---|
66 | \li NumRes(op) == 1 |
---|
67 | \li i_x < i_z |
---|
68 | \li q < cap_order |
---|
69 | \li p <= q |
---|
70 | */ |
---|
71 | template <class Base> |
---|
72 | inline void forward_unary1_op( |
---|
73 | size_t p , |
---|
74 | size_t q , |
---|
75 | size_t i_z , |
---|
76 | size_t i_x , |
---|
77 | size_t cap_order , |
---|
78 | Base* taylor ) |
---|
79 | { |
---|
80 | // This routine is only for documentaiton, it should not be used |
---|
81 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
82 | } |
---|
83 | |
---|
84 | /*! |
---|
85 | Prototype for multiple direction forward mode unary operator with one result |
---|
86 | (not used). |
---|
87 | |
---|
88 | \tparam Base |
---|
89 | base type for the operator; i.e., this operation was recorded |
---|
90 | using AD< \a Base > and computations by this routine are done using type |
---|
91 | \a Base. |
---|
92 | |
---|
93 | \param q |
---|
94 | order of the Taylor coefficients that we are computing. |
---|
95 | |
---|
96 | \param r |
---|
97 | number of directions for Taylor coefficients that we are computing. |
---|
98 | |
---|
99 | \param i_z |
---|
100 | variable index corresponding to the last (primary) result for this operation; |
---|
101 | i.e. the row index in \a taylor corresponding to z. |
---|
102 | The auxillary result is called y has index \a i_z - 1. |
---|
103 | |
---|
104 | \param i_x |
---|
105 | variable index corresponding to the argument for this operator; |
---|
106 | i.e. the row index in \a taylor corresponding to x. |
---|
107 | |
---|
108 | \param cap_order |
---|
109 | maximum number of orders that will fit in the \c taylor array. |
---|
110 | |
---|
111 | \par tpv |
---|
112 | We use the notation |
---|
113 | <code>tpv = (cap_order-1) * r + 1</code> |
---|
114 | which is the number of Taylor coefficients per variable |
---|
115 | |
---|
116 | \param taylor |
---|
117 | \b Input: If x is a variable, |
---|
118 | <code>taylor [ arg[0] * tpv + 0 ]</code>, |
---|
119 | is the zero order Taylor coefficient for all directions and |
---|
120 | <code>taylor [ arg[0] * tpv + (k-1)*r + ell + 1 ]</code>, |
---|
121 | for k = 1 , ... , q, |
---|
122 | ell = 0, ..., r-1, |
---|
123 | is the k-th order Taylor coefficient |
---|
124 | corresponding to x and the ell-th direction. |
---|
125 | \n |
---|
126 | \b Input: <code>taylor [ i_z * tpv + 0 ]</code>, |
---|
127 | is the zero order Taylor coefficient for all directions and |
---|
128 | <code>taylor [ i_z * tpv + (k-1)*r + ell + 1 ]</code>, |
---|
129 | for k = 1 , ... , q-1, |
---|
130 | ell = 0, ..., r-1, |
---|
131 | is the k-th order Taylor coefficient |
---|
132 | corresponding to z and the ell-th direction. |
---|
133 | \n |
---|
134 | \b Output: |
---|
135 | <code>taylor [ i_z * tpv + (q-1)*r + ell + 1]</code>, |
---|
136 | ell = 0, ..., r-1, |
---|
137 | is the q-th order Taylor coefficient |
---|
138 | corresponding to z and the ell-th direction. |
---|
139 | |
---|
140 | \par Checked Assertions |
---|
141 | \li NumArg(op) == 1 |
---|
142 | \li NumRes(op) == 2 |
---|
143 | \li i_x < i_z |
---|
144 | \li 0 < q |
---|
145 | \li q < cap_order |
---|
146 | */ |
---|
147 | template <class Base> |
---|
148 | inline void forward_unary1_op_dir( |
---|
149 | size_t q , |
---|
150 | size_t r , |
---|
151 | size_t i_z , |
---|
152 | size_t i_x , |
---|
153 | size_t cap_order , |
---|
154 | Base* taylor ) |
---|
155 | { |
---|
156 | // This routine is only for documentaiton, it should not be used |
---|
157 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
158 | } |
---|
159 | |
---|
160 | /*! |
---|
161 | Prototype for zero order forward mode unary operator with one result (not used). |
---|
162 | \tparam Base |
---|
163 | base type for the operator; i.e., this operation was recorded |
---|
164 | using AD< \a Base > and computations by this routine are done using type |
---|
165 | \a Base . |
---|
166 | |
---|
167 | \param i_z |
---|
168 | variable index corresponding to the result for this operation; |
---|
169 | i.e. the row index in \a taylor corresponding to z. |
---|
170 | |
---|
171 | \param i_x |
---|
172 | variable index corresponding to the argument for this operator; |
---|
173 | i.e. the row index in \a taylor corresponding to x. |
---|
174 | |
---|
175 | \param cap_order |
---|
176 | maximum number of orders that will fit in the \c taylor array. |
---|
177 | |
---|
178 | \param taylor |
---|
179 | \b Input: \a taylor [ \a i_x * \a cap_order + 0 ] |
---|
180 | is the zero order Taylor coefficient corresponding to x. |
---|
181 | \n |
---|
182 | \b Output: \a taylor [ \a i_z * \a cap_order + 0 ] |
---|
183 | is the zero order Taylor coefficient corresponding to z. |
---|
184 | |
---|
185 | \par Checked Assertions |
---|
186 | \li NumArg(op) == 1 |
---|
187 | \li NumRes(op) == 1 |
---|
188 | \li \a i_x < \a i_z |
---|
189 | \li \a 0 < \a cap_order |
---|
190 | */ |
---|
191 | template <class Base> |
---|
192 | inline void forward_unary1_op_0( |
---|
193 | size_t i_z , |
---|
194 | size_t i_x , |
---|
195 | size_t cap_order , |
---|
196 | Base* taylor ) |
---|
197 | { |
---|
198 | // This routine is only for documentaiton, it should not be used |
---|
199 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
200 | } |
---|
201 | |
---|
202 | /*! |
---|
203 | Prototype for reverse mode unary operator with one result (not used). |
---|
204 | |
---|
205 | This routine is given the partial derivatives of a function |
---|
206 | G(z , x , w, u ... ) |
---|
207 | and it uses them to compute the partial derivatives of |
---|
208 | \verbatim |
---|
209 | H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] |
---|
210 | \endverbatim |
---|
211 | |
---|
212 | \tparam Base |
---|
213 | base type for the operator; i.e., this operation was recorded |
---|
214 | using AD< \a Base > and computations by this routine are done using type |
---|
215 | \a Base . |
---|
216 | |
---|
217 | \param d |
---|
218 | highest order Taylor coefficient that |
---|
219 | we are computing the partial derivatives with respect to. |
---|
220 | |
---|
221 | \param i_z |
---|
222 | variable index corresponding to the result for this operation; |
---|
223 | i.e. the row index in \a taylor to z. |
---|
224 | |
---|
225 | \param i_x |
---|
226 | variable index corresponding to the argument for this operation; |
---|
227 | i.e. the row index in \a taylor corresponding to x. |
---|
228 | |
---|
229 | \param cap_order |
---|
230 | maximum number of orders that will fit in the \c taylor array. |
---|
231 | |
---|
232 | \param taylor |
---|
233 | \a taylor [ \a i_x * \a cap_order + k ] |
---|
234 | for k = 0 , ... , \a d |
---|
235 | is the k-th order Taylor coefficient corresponding to x. |
---|
236 | \n |
---|
237 | \a taylor [ \a i_z * \a cap_order + k ] |
---|
238 | for k = 0 , ... , \a d |
---|
239 | is the k-th order Taylor coefficient corresponding to z. |
---|
240 | |
---|
241 | \param nc_partial |
---|
242 | number of colums in the matrix containing all the partial derivatives. |
---|
243 | |
---|
244 | \param partial |
---|
245 | \b Input: \a partial [ \a i_x * \a nc_partial + k ] |
---|
246 | for k = 0 , ... , \a d |
---|
247 | is the partial derivative of G( z , x , w , u , ... ) with respect to |
---|
248 | the k-th order Taylor coefficient for x. |
---|
249 | \n |
---|
250 | \b Input: \a partial [ \a i_z * \a nc_partial + k ] |
---|
251 | for k = 0 , ... , \a d |
---|
252 | is the partial derivative of G( z , x , w , u , ... ) with respect to |
---|
253 | the k-th order Taylor coefficient for z. |
---|
254 | \n |
---|
255 | \b Output: \a partial [ \a i_x * \a nc_partial + k ] |
---|
256 | for k = 0 , ... , \a d |
---|
257 | is the partial derivative of H( x , w , u , ... ) with respect to |
---|
258 | the k-th order Taylor coefficient for x. |
---|
259 | \n |
---|
260 | \b Output: \a partial [ \a i_z * \a nc_partial + k ] |
---|
261 | for k = 0 , ... , \a d |
---|
262 | may be used as work space; i.e., may change in an unspecified manner. |
---|
263 | |
---|
264 | |
---|
265 | \par Checked Assumptions |
---|
266 | \li NumArg(op) == 1 |
---|
267 | \li NumRes(op) == 1 |
---|
268 | \li \a i_x < \a i_z |
---|
269 | \li \a d < \a cap_order |
---|
270 | \li \a d < \a nc_partial |
---|
271 | */ |
---|
272 | template <class Base> |
---|
273 | inline void reverse_unary1_op( |
---|
274 | size_t d , |
---|
275 | size_t i_z , |
---|
276 | size_t i_x , |
---|
277 | size_t cap_order , |
---|
278 | const Base* taylor , |
---|
279 | size_t nc_partial , |
---|
280 | Base* partial ) |
---|
281 | { |
---|
282 | // This routine is only for documentaiton, it should not be used |
---|
283 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
284 | } |
---|
285 | |
---|
286 | // ==================== Unary operators with two results ==================== |
---|
287 | |
---|
288 | /*! |
---|
289 | Prototype for forward mode unary operator with two results (not used). |
---|
290 | |
---|
291 | \tparam Base |
---|
292 | base type for the operator; i.e., this operation was recorded |
---|
293 | using AD< \a Base > and computations by this routine are done using type |
---|
294 | \a Base. |
---|
295 | |
---|
296 | \param p |
---|
297 | lowest order of the Taylor coefficients that we are computing. |
---|
298 | |
---|
299 | \param q |
---|
300 | highest order of the Taylor coefficients that we are computing. |
---|
301 | |
---|
302 | \param i_z |
---|
303 | variable index corresponding to the last (primary) result for this operation; |
---|
304 | i.e. the row index in \a taylor corresponding to z. |
---|
305 | The auxillary result is called y has index \a i_z - 1. |
---|
306 | |
---|
307 | \param i_x |
---|
308 | variable index corresponding to the argument for this operator; |
---|
309 | i.e. the row index in \a taylor corresponding to x. |
---|
310 | |
---|
311 | \param cap_order |
---|
312 | maximum number of orders that will fit in the \c taylor array. |
---|
313 | |
---|
314 | \param taylor |
---|
315 | \b Input: <code>taylor [ i_x * cap_order + k ]</code> |
---|
316 | for k = 0 , ... , q, |
---|
317 | is the k-th order Taylor coefficient corresponding to x. |
---|
318 | \n |
---|
319 | \b Input: <code>taylor [ i_z * cap_order + k ]</code> |
---|
320 | for k = 0 , ... , p - 1, |
---|
321 | is the k-th order Taylor coefficient corresponding to z. |
---|
322 | \n |
---|
323 | \b Input: <code>taylor [ ( i_z - 1) * cap_order + k ]</code> |
---|
324 | for k = 0 , ... , p-1, |
---|
325 | is the k-th order Taylor coefficient corresponding to the auxillary result y. |
---|
326 | \n |
---|
327 | \b Output: <code>taylor [ i_z * cap_order + k ]</code>, |
---|
328 | for k = p , ... , q, |
---|
329 | is the k-th order Taylor coefficient corresponding to z. |
---|
330 | \n |
---|
331 | \b Output: <code>taylor [ ( i_z - 1 ) * cap_order + k ]</code>, |
---|
332 | for k = p , ... , q, |
---|
333 | is the k-th order Taylor coefficient corresponding to |
---|
334 | the autillary result y. |
---|
335 | |
---|
336 | \par Checked Assertions |
---|
337 | \li NumArg(op) == 1 |
---|
338 | \li NumRes(op) == 2 |
---|
339 | \li i_x + 1 < i_z |
---|
340 | \li q < cap_order |
---|
341 | \li p <= q |
---|
342 | */ |
---|
343 | template <class Base> |
---|
344 | inline void forward_unary2_op( |
---|
345 | size_t p , |
---|
346 | size_t q , |
---|
347 | size_t i_z , |
---|
348 | size_t i_x , |
---|
349 | size_t cap_order , |
---|
350 | Base* taylor ) |
---|
351 | { |
---|
352 | // This routine is only for documentaiton, it should not be used |
---|
353 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
354 | } |
---|
355 | |
---|
356 | /*! |
---|
357 | Prototype for multiple direction forward mode unary operator with two results |
---|
358 | (not used). |
---|
359 | |
---|
360 | \tparam Base |
---|
361 | base type for the operator; i.e., this operation was recorded |
---|
362 | using AD< \a Base > and computations by this routine are done using type |
---|
363 | \a Base. |
---|
364 | |
---|
365 | \param q |
---|
366 | order of the Taylor coefficients that we are computing. |
---|
367 | |
---|
368 | \param r |
---|
369 | number of directions for Taylor coefficients that we are computing. |
---|
370 | |
---|
371 | \param i_z |
---|
372 | variable index corresponding to the last (primary) result for this operation; |
---|
373 | i.e. the row index in \a taylor corresponding to z. |
---|
374 | The auxillary result is called y has index \a i_z - 1. |
---|
375 | |
---|
376 | \param i_x |
---|
377 | variable index corresponding to the argument for this operator; |
---|
378 | i.e. the row index in \a taylor corresponding to x. |
---|
379 | |
---|
380 | \param cap_order |
---|
381 | maximum number of orders that will fit in the \c taylor array. |
---|
382 | |
---|
383 | \par tpv |
---|
384 | We use the notation |
---|
385 | <code>tpv = (cap_order-1) * r + 1</code> |
---|
386 | which is the number of Taylor coefficients per variable |
---|
387 | |
---|
388 | \param taylor |
---|
389 | \b Input: <code>taylor [ i_x * tpv + 0 ]</code> |
---|
390 | is the zero order Taylor coefficient for all directions and |
---|
391 | <code>taylor [ i_x * tpv + (k-1)*r + ell + 1</code> |
---|
392 | for k = 1 , ... , q, |
---|
393 | ell = 0 , ..., r-1, |
---|
394 | is the k-th order Taylor coefficient |
---|
395 | corresponding to x and the ell-th direction. |
---|
396 | \n |
---|
397 | \b Input: <code>taylor [ i_z * tpv + 0 ]</code>, |
---|
398 | is the zero order Taylor coefficient for all directions and |
---|
399 | <code>taylor [ i_z * tpv + (k-1)*r + ell + 1 ]</code>, |
---|
400 | for k = 1 , ... , q-1, |
---|
401 | ell = 0, ..., r-1, |
---|
402 | is the k-th order Taylor coefficient |
---|
403 | corresponding to z and the ell-th direction. |
---|
404 | \n |
---|
405 | \b Input: <code>taylor [ (i_z-1) * tpv + 0 ]</code>, |
---|
406 | is the zero order Taylor coefficient for all directions and |
---|
407 | <code>taylor [ (i_z-1) * tpv + (k-1)*r + ell + 1 ]</code>, |
---|
408 | for k = 1 , ... , q-1, |
---|
409 | ell = 0, ..., r-1, |
---|
410 | is the k-th order Taylor coefficient |
---|
411 | corresponding to the auxillary result y and the ell-th direction. |
---|
412 | \n |
---|
413 | \b Output: |
---|
414 | <code>taylor [ i_z * tpv + (q-1)*r + ell + 1]</code>, |
---|
415 | ell = 0, ..., r-1, |
---|
416 | is the q-th order Taylor coefficient |
---|
417 | corresponding to z and the ell-th direction. |
---|
418 | |
---|
419 | \par Checked Assertions |
---|
420 | \li NumArg(op) == 1 |
---|
421 | \li NumRes(op) == 2 |
---|
422 | \li i_x + 1 < i_z |
---|
423 | \li 0 < q |
---|
424 | \li q < cap_order |
---|
425 | */ |
---|
426 | template <class Base> |
---|
427 | inline void forward_unary2_op_dir( |
---|
428 | size_t q , |
---|
429 | size_t r , |
---|
430 | size_t i_z , |
---|
431 | size_t i_x , |
---|
432 | size_t cap_order , |
---|
433 | Base* taylor ) |
---|
434 | { |
---|
435 | // This routine is only for documentaiton, it should not be used |
---|
436 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
437 | } |
---|
438 | |
---|
439 | /*! |
---|
440 | Prototype for zero order forward mode unary operator with two results (not used). |
---|
441 | \tparam Base |
---|
442 | base type for the operator; i.e., this operation was recorded |
---|
443 | using AD< \a Base > and computations by this routine are done using type |
---|
444 | \a Base . |
---|
445 | |
---|
446 | \param i_z |
---|
447 | variable index corresponding to the last (primary) result for this operation; |
---|
448 | i.e. the row index in \a taylor corresponding to z. |
---|
449 | The auxillary result is called y and has index \a i_z - 1. |
---|
450 | |
---|
451 | \param i_x |
---|
452 | variable index corresponding to the argument for this operator; |
---|
453 | i.e. the row index in \a taylor corresponding to x. |
---|
454 | |
---|
455 | \param cap_order |
---|
456 | maximum number of orders that will fit in the \c taylor array. |
---|
457 | |
---|
458 | \param taylor |
---|
459 | \b Input: \a taylor [ \a i_x * \a cap_order + 0 ] |
---|
460 | is the zero order Taylor coefficient corresponding to x. |
---|
461 | \n |
---|
462 | \b Output: \a taylor [ \a i_z * \a cap_order + 0 ] |
---|
463 | is the zero order Taylor coefficient corresponding to z. |
---|
464 | \n |
---|
465 | \b Output: \a taylor [ ( \a i_z - 1 ) * \a cap_order + j ] |
---|
466 | is the j-th order Taylor coefficient corresponding to |
---|
467 | the autillary result y. |
---|
468 | |
---|
469 | \par Checked Assertions |
---|
470 | \li NumArg(op) == 1 |
---|
471 | \li NumRes(op) == 2 |
---|
472 | \li \a i_x + 1 < \a i_z |
---|
473 | \li \a j < \a cap_order |
---|
474 | */ |
---|
475 | template <class Base> |
---|
476 | inline void forward_unary2_op_0( |
---|
477 | size_t i_z , |
---|
478 | size_t i_x , |
---|
479 | size_t cap_order , |
---|
480 | Base* taylor ) |
---|
481 | { |
---|
482 | // This routine is only for documentaiton, it should not be used |
---|
483 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
484 | } |
---|
485 | |
---|
486 | /*! |
---|
487 | Prototype for reverse mode unary operator with two results (not used). |
---|
488 | |
---|
489 | This routine is given the partial derivatives of a function |
---|
490 | G( z , y , x , w , ... ) |
---|
491 | and it uses them to compute the partial derivatives of |
---|
492 | \verbatim |
---|
493 | H( x , w , u , ... ) = G[ z(x) , y(x), x , w , u , ... ] |
---|
494 | \endverbatim |
---|
495 | |
---|
496 | \tparam Base |
---|
497 | base type for the operator; i.e., this operation was recorded |
---|
498 | using AD< \a Base > and computations by this routine are done using type |
---|
499 | \a Base . |
---|
500 | |
---|
501 | \param d |
---|
502 | highest order Taylor coefficient that |
---|
503 | we are computing the partial derivatives with respect to. |
---|
504 | |
---|
505 | \param i_z |
---|
506 | variable index corresponding to the last (primary) result for this operation; |
---|
507 | i.e. the row index in \a taylor to z. |
---|
508 | The auxillary result is called y and has index \a i_z - 1. |
---|
509 | |
---|
510 | \param i_x |
---|
511 | variable index corresponding to the argument for this operation; |
---|
512 | i.e. the row index in \a taylor corresponding to x. |
---|
513 | |
---|
514 | \param cap_order |
---|
515 | maximum number of orders that will fit in the \c taylor array. |
---|
516 | |
---|
517 | \param taylor |
---|
518 | \a taylor [ \a i_x * \a cap_order + k ] |
---|
519 | for k = 0 , ... , \a d |
---|
520 | is the k-th order Taylor coefficient corresponding to x. |
---|
521 | \n |
---|
522 | \a taylor [ \a i_z * \a cap_order + k ] |
---|
523 | for k = 0 , ... , \a d |
---|
524 | is the k-th order Taylor coefficient corresponding to z. |
---|
525 | \n |
---|
526 | \a taylor [ ( \a i_z - 1) * \a cap_order + k ] |
---|
527 | for k = 0 , ... , \a d |
---|
528 | is the k-th order Taylor coefficient corresponding to |
---|
529 | the auxillary variable y. |
---|
530 | |
---|
531 | \param nc_partial |
---|
532 | number of colums in the matrix containing all the partial derivatives. |
---|
533 | |
---|
534 | \param partial |
---|
535 | \b Input: \a partial [ \a i_x * \a nc_partial + k ] |
---|
536 | for k = 0 , ... , \a d |
---|
537 | is the partial derivative of |
---|
538 | G( z , y , x , w , u , ... ) |
---|
539 | with respect to the k-th order Taylor coefficient for x. |
---|
540 | \n |
---|
541 | \b Input: \a partial [ \a i_z * \a nc_partial + k ] |
---|
542 | for k = 0 , ... , \a d |
---|
543 | is the partial derivative of G( z , y , x , w , u , ... ) with respect to |
---|
544 | the k-th order Taylor coefficient for z. |
---|
545 | \n |
---|
546 | \b Input: \a partial [ ( \a i_z - 1) * \a nc_partial + k ] |
---|
547 | for k = 0 , ... , \a d |
---|
548 | is the partial derivative of G( z , x , w , u , ... ) with respect to |
---|
549 | the k-th order Taylor coefficient for the auxillary variable y. |
---|
550 | \n |
---|
551 | \b Output: \a partial [ \a i_x * \a nc_partial + k ] |
---|
552 | for k = 0 , ... , \a d |
---|
553 | is the partial derivative of H( x , w , u , ... ) with respect to |
---|
554 | the k-th order Taylor coefficient for x. |
---|
555 | \n |
---|
556 | \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] |
---|
557 | for j = 0 , 1 , and for k = 0 , ... , \a d |
---|
558 | may be used as work space; i.e., may change in an unspecified manner. |
---|
559 | |
---|
560 | |
---|
561 | \par Checked Assumptions |
---|
562 | \li NumArg(op) == 1 |
---|
563 | \li NumRes(op) == 2 |
---|
564 | \li \a i_x + 1 < \a i_z |
---|
565 | \li \a d < \a cap_order |
---|
566 | \li \a d < \a nc_partial |
---|
567 | */ |
---|
568 | template <class Base> |
---|
569 | inline void reverse_unary2_op( |
---|
570 | size_t d , |
---|
571 | size_t i_z , |
---|
572 | size_t i_x , |
---|
573 | size_t cap_order , |
---|
574 | const Base* taylor , |
---|
575 | size_t nc_partial , |
---|
576 | Base* partial ) |
---|
577 | { |
---|
578 | // This routine is only for documentaiton, it should not be used |
---|
579 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
580 | } |
---|
581 | // =================== Binary operators with one result ==================== |
---|
582 | |
---|
583 | /*! |
---|
584 | Prototype forward mode x op y (not used) |
---|
585 | |
---|
586 | \tparam Base |
---|
587 | base type for the operator; i.e., this operation was recorded |
---|
588 | using AD< \a Base > and computations by this routine are done using type |
---|
589 | \a Base. |
---|
590 | |
---|
591 | \param p |
---|
592 | lowest order of the Taylor coefficient that we are computing. |
---|
593 | |
---|
594 | \param q |
---|
595 | highest order of the Taylor coefficient that we are computing. |
---|
596 | |
---|
597 | \param i_z |
---|
598 | variable index corresponding to the result for this operation; |
---|
599 | i.e. the row index in \a taylor corresponding to z. |
---|
600 | |
---|
601 | \param arg |
---|
602 | \a arg[0] |
---|
603 | index corresponding to the left operand for this operator; |
---|
604 | i.e. the index corresponding to x. |
---|
605 | \n |
---|
606 | \a arg[1] |
---|
607 | index corresponding to the right operand for this operator; |
---|
608 | i.e. the index corresponding to y. |
---|
609 | |
---|
610 | \param parameter |
---|
611 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
612 | is the value corresponding to x. |
---|
613 | \n |
---|
614 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
615 | is the value corresponding to y. |
---|
616 | |
---|
617 | \param cap_order |
---|
618 | maximum number of orders that will fit in the \c taylor array. |
---|
619 | |
---|
620 | \param taylor |
---|
621 | \b Input: If x is a variable, |
---|
622 | <code>taylor [ arg[0] * cap_order + k ]</code>, |
---|
623 | for k = 0 , ... , q, |
---|
624 | is the k-th order Taylor coefficient corresponding to x. |
---|
625 | \n |
---|
626 | \b Input: If y is a variable, |
---|
627 | <code>taylor [ arg[1] * cap_order + k ]</code>, |
---|
628 | for k = 0 , ... , q, |
---|
629 | is the k-th order Taylor coefficient corresponding to y. |
---|
630 | \n |
---|
631 | \b Input: <code>taylor [ i_z * cap_order + k ]</code>, |
---|
632 | for k = 0 , ... , p-1, |
---|
633 | is the k-th order Taylor coefficient corresponding to z. |
---|
634 | \n |
---|
635 | \b Output: <code>taylor [ i_z * cap_order + k ]</code>, |
---|
636 | for k = p, ... , q, |
---|
637 | is the k-th order Taylor coefficient corresponding to z. |
---|
638 | |
---|
639 | \par Checked Assertions |
---|
640 | \li NumArg(op) == 2 |
---|
641 | \li NumRes(op) == 1 |
---|
642 | \li If x is a variable, arg[0] < i_z |
---|
643 | \li If y is a variable, arg[1] < i_z |
---|
644 | \li q < cap_order |
---|
645 | \li p <= q |
---|
646 | */ |
---|
647 | template <class Base> |
---|
648 | inline void forward_binary_op( |
---|
649 | size_t p , |
---|
650 | size_t q , |
---|
651 | size_t i_z , |
---|
652 | const addr_t* arg , |
---|
653 | const Base* parameter , |
---|
654 | size_t cap_order , |
---|
655 | Base* taylor ) |
---|
656 | { |
---|
657 | // This routine is only for documentaiton, it should not be used |
---|
658 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
659 | } |
---|
660 | |
---|
661 | /*! |
---|
662 | Prototype multiple direction forward mode x op y (not used) |
---|
663 | |
---|
664 | \tparam Base |
---|
665 | base type for the operator; i.e., this operation was recorded |
---|
666 | using AD< \a Base > and computations by this routine are done using type |
---|
667 | \a Base. |
---|
668 | |
---|
669 | \param q |
---|
670 | is the order of the Taylor coefficients that we are computing. |
---|
671 | |
---|
672 | \param r |
---|
673 | number of directions for Taylor coefficients that we are computing |
---|
674 | |
---|
675 | \param i_z |
---|
676 | variable index corresponding to the result for this operation; |
---|
677 | i.e. the row index in \a taylor corresponding to z. |
---|
678 | |
---|
679 | \param arg |
---|
680 | \a arg[0] |
---|
681 | index corresponding to the left operand for this operator; |
---|
682 | i.e. the index corresponding to x. |
---|
683 | \n |
---|
684 | \a arg[1] |
---|
685 | index corresponding to the right operand for this operator; |
---|
686 | i.e. the index corresponding to y. |
---|
687 | |
---|
688 | \param parameter |
---|
689 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
690 | is the value corresponding to x. |
---|
691 | \n |
---|
692 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
693 | is the value corresponding to y. |
---|
694 | |
---|
695 | \param cap_order |
---|
696 | maximum number of orders that will fit in the \c taylor array. |
---|
697 | |
---|
698 | \par tpv |
---|
699 | We use the notation |
---|
700 | <code>tpv = (cap_order-1) * r + 1</code> |
---|
701 | which is the number of Taylor coefficients per variable |
---|
702 | |
---|
703 | \param taylor |
---|
704 | \b Input: If x is a variable, |
---|
705 | <code>taylor [ arg[0] * tpv + 0 ]</code>, |
---|
706 | is the zero order Taylor coefficient for all directions and |
---|
707 | <code>taylor [ arg[0] * tpv + (k-1)*r + ell + 1 ]</code>, |
---|
708 | for k = 1 , ... , q, |
---|
709 | ell = 0, ..., r-1, |
---|
710 | is the k-th order Taylor coefficient |
---|
711 | corresponding to x and the ell-th direction. |
---|
712 | \n |
---|
713 | \b Input: If y is a variable, |
---|
714 | <code>taylor [ arg[1] * tpv + 0 ]</code>, |
---|
715 | is the zero order Taylor coefficient for all directions and |
---|
716 | <code>taylor [ arg[1] * tpv + (k-1)*r + ell + 1 ]</code>, |
---|
717 | for k = 1 , ... , q, |
---|
718 | ell = 0, ..., r-1, |
---|
719 | is the k-th order Taylor coefficient |
---|
720 | corresponding to y and the ell-th direction. |
---|
721 | \n |
---|
722 | \b Input: <code>taylor [ i_z * tpv + 0 ]</code>, |
---|
723 | is the zero order Taylor coefficient for all directions and |
---|
724 | <code>taylor [ i_z * tpv + (k-1)*r + ell + 1 ]</code>, |
---|
725 | for k = 1 , ... , q-1, |
---|
726 | ell = 0, ..., r-1, |
---|
727 | is the k-th order Taylor coefficient |
---|
728 | corresponding to z and the ell-th direction. |
---|
729 | \n |
---|
730 | \b Output: |
---|
731 | <code>taylor [ i_z * tpv + (q-1)*r + ell + 1]</code>, |
---|
732 | ell = 0, ..., r-1, |
---|
733 | is the q-th order Taylor coefficient |
---|
734 | corresponding to z and the ell-th direction. |
---|
735 | |
---|
736 | \par Checked Assertions |
---|
737 | \li NumArg(op) == 2 |
---|
738 | \li NumRes(op) == 1 |
---|
739 | \li If x is a variable, arg[0] < i_z |
---|
740 | \li If y is a variable, arg[1] < i_z |
---|
741 | \li 0 < q < cap_order |
---|
742 | */ |
---|
743 | template <class Base> |
---|
744 | inline void forward_binary_op_dir( |
---|
745 | size_t q , |
---|
746 | size_t r , |
---|
747 | size_t i_z , |
---|
748 | const addr_t* arg , |
---|
749 | const Base* parameter , |
---|
750 | size_t cap_order , |
---|
751 | Base* taylor ) |
---|
752 | { |
---|
753 | // This routine is only for documentaiton, it should not be used |
---|
754 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
755 | } |
---|
756 | |
---|
757 | |
---|
758 | /*! |
---|
759 | Prototype zero order forward mode x op y (not used) |
---|
760 | |
---|
761 | \tparam Base |
---|
762 | base type for the operator; i.e., this operation was recorded |
---|
763 | using AD< \a Base > and computations by this routine are done using type |
---|
764 | \a Base. |
---|
765 | |
---|
766 | \param i_z |
---|
767 | variable index corresponding to the result for this operation; |
---|
768 | i.e. the row index in \a taylor corresponding to z. |
---|
769 | |
---|
770 | \param arg |
---|
771 | \a arg[0] |
---|
772 | index corresponding to the left operand for this operator; |
---|
773 | i.e. the index corresponding to x. |
---|
774 | \n |
---|
775 | \a arg[1] |
---|
776 | index corresponding to the right operand for this operator; |
---|
777 | i.e. the index corresponding to y. |
---|
778 | |
---|
779 | \param parameter |
---|
780 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
781 | is the value corresponding to x. |
---|
782 | \n |
---|
783 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
784 | is the value corresponding to y. |
---|
785 | |
---|
786 | \param cap_order |
---|
787 | maximum number of orders that will fit in the \c taylor array. |
---|
788 | |
---|
789 | \param taylor |
---|
790 | \b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] |
---|
791 | is the zero order Taylor coefficient corresponding to x. |
---|
792 | \n |
---|
793 | \b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] |
---|
794 | is the zero order Taylor coefficient corresponding to y. |
---|
795 | \n |
---|
796 | \b Output: \a taylor [ \a i_z * \a cap_order + 0 ] |
---|
797 | is the zero order Taylor coefficient corresponding to z. |
---|
798 | |
---|
799 | \par Checked Assertions |
---|
800 | \li NumArg(op) == 2 |
---|
801 | \li NumRes(op) == 1 |
---|
802 | \li If x is a variable, \a arg[0] < \a i_z |
---|
803 | \li If y is a variable, \a arg[1] < \a i_z |
---|
804 | */ |
---|
805 | template <class Base> |
---|
806 | inline void forward_binary_op_0( |
---|
807 | size_t i_z , |
---|
808 | const addr_t* arg , |
---|
809 | const Base* parameter , |
---|
810 | size_t cap_order , |
---|
811 | Base* taylor ) |
---|
812 | { |
---|
813 | // This routine is only for documentaiton, it should not be used |
---|
814 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
815 | } |
---|
816 | |
---|
817 | /*! |
---|
818 | Prototype for reverse mode binary operator x op y (not used). |
---|
819 | |
---|
820 | This routine is given the partial derivatives of a function |
---|
821 | G( z , y , x , w , ... ) |
---|
822 | and it uses them to compute the partial derivatives of |
---|
823 | \verbatim |
---|
824 | H( y , x , w , u , ... ) = G[ z(x , y) , y , x , w , u , ... ] |
---|
825 | \endverbatim |
---|
826 | |
---|
827 | \tparam Base |
---|
828 | base type for the operator; i.e., this operation was recorded |
---|
829 | using AD< \a Base > and computations by this routine are done using type |
---|
830 | \a Base . |
---|
831 | |
---|
832 | \param d |
---|
833 | highest order Taylor coefficient that |
---|
834 | we are computing the partial derivatives with respect to. |
---|
835 | |
---|
836 | \param i_z |
---|
837 | variable index corresponding to the result for this operation; |
---|
838 | i.e. the row index in \a taylor corresponding to z. |
---|
839 | |
---|
840 | \param arg |
---|
841 | \a arg[0] |
---|
842 | index corresponding to the left operand for this operator; |
---|
843 | i.e. the index corresponding to x. |
---|
844 | \n |
---|
845 | \a arg[1] |
---|
846 | index corresponding to the right operand for this operator; |
---|
847 | i.e. the index corresponding to y. |
---|
848 | |
---|
849 | \param parameter |
---|
850 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
851 | is the value corresponding to x. |
---|
852 | \n |
---|
853 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
854 | is the value corresponding to y. |
---|
855 | |
---|
856 | \param cap_order |
---|
857 | maximum number of orders that will fit in the \c taylor array. |
---|
858 | |
---|
859 | \param taylor |
---|
860 | \a taylor [ \a i_z * \a cap_order + k ] |
---|
861 | for k = 0 , ... , \a d |
---|
862 | is the k-th order Taylor coefficient corresponding to z. |
---|
863 | \n |
---|
864 | If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] |
---|
865 | for k = 0 , ... , \a d |
---|
866 | is the k-th order Taylor coefficient corresponding to x. |
---|
867 | \n |
---|
868 | If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] |
---|
869 | for k = 0 , ... , \a d |
---|
870 | is the k-th order Taylor coefficient corresponding to y. |
---|
871 | |
---|
872 | \param nc_partial |
---|
873 | number of colums in the matrix containing all the partial derivatives. |
---|
874 | |
---|
875 | \param partial |
---|
876 | \b Input: \a partial [ \a i_z * \a nc_partial + k ] |
---|
877 | for k = 0 , ... , \a d |
---|
878 | is the partial derivative of |
---|
879 | G( z , y , x , w , u , ... ) |
---|
880 | with respect to the k-th order Taylor coefficient for z. |
---|
881 | \n |
---|
882 | \b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] |
---|
883 | for k = 0 , ... , \a d |
---|
884 | is the partial derivative of G( z , y , x , w , u , ... ) with respect to |
---|
885 | the k-th order Taylor coefficient for x. |
---|
886 | \n |
---|
887 | \b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] |
---|
888 | for k = 0 , ... , \a d |
---|
889 | is the partial derivative of G( z , x , w , u , ... ) with respect to |
---|
890 | the k-th order Taylor coefficient for the auxillary variable y. |
---|
891 | \n |
---|
892 | \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] |
---|
893 | for k = 0 , ... , \a d |
---|
894 | is the partial derivative of H( y , x , w , u , ... ) with respect to |
---|
895 | the k-th order Taylor coefficient for x. |
---|
896 | \n |
---|
897 | \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] |
---|
898 | for k = 0 , ... , \a d |
---|
899 | is the partial derivative of H( y , x , w , u , ... ) with respect to |
---|
900 | the k-th order Taylor coefficient for y. |
---|
901 | \n |
---|
902 | \b Output: \a partial [ \a i_z * \a nc_partial + k ] |
---|
903 | for k = 0 , ... , \a d |
---|
904 | may be used as work space; i.e., may change in an unspecified manner. |
---|
905 | |
---|
906 | \par Checked Assumptions |
---|
907 | \li NumArg(op) == 2 |
---|
908 | \li NumRes(op) == 1 |
---|
909 | \li \a If x is a variable, arg[0] < \a i_z |
---|
910 | \li \a If y is a variable, arg[1] < \a i_z |
---|
911 | \li \a d < \a cap_order |
---|
912 | \li \a d < \a nc_partial |
---|
913 | */ |
---|
914 | template <class Base> |
---|
915 | inline void reverse_binary_op( |
---|
916 | size_t d , |
---|
917 | size_t i_z , |
---|
918 | addr_t* arg , |
---|
919 | const Base* parameter , |
---|
920 | size_t cap_order , |
---|
921 | const Base* taylor , |
---|
922 | size_t nc_partial , |
---|
923 | Base* partial ) |
---|
924 | { |
---|
925 | // This routine is only for documentaiton, it should not be used |
---|
926 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
927 | } |
---|
928 | // ======================= Pow Function =================================== |
---|
929 | /*! |
---|
930 | Prototype for forward mode z = pow(x, y) (not used). |
---|
931 | |
---|
932 | \tparam Base |
---|
933 | base type for the operator; i.e., this operation was recorded |
---|
934 | using AD< \a Base > and computations by this routine are done using type |
---|
935 | \a Base. |
---|
936 | |
---|
937 | \param p |
---|
938 | lowest order of the Taylor coefficient that we are computing. |
---|
939 | |
---|
940 | \param q |
---|
941 | highest order of the Taylor coefficient that we are computing. |
---|
942 | |
---|
943 | \param i_z |
---|
944 | variable index corresponding to the last (primary) result for this operation; |
---|
945 | i.e. the row index in \a taylor corresponding to z. |
---|
946 | Note that there are three results for this operation, |
---|
947 | below they are referred to as z_0, z_1, z_2 and correspond to |
---|
948 | \verbatim |
---|
949 | z_0 = log(x) |
---|
950 | z_1 = z0 * y |
---|
951 | z_2 = exp(z1) |
---|
952 | \endverbatim |
---|
953 | It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). |
---|
954 | |
---|
955 | \param arg |
---|
956 | \a arg[0] |
---|
957 | index corresponding to the left operand for this operator; |
---|
958 | i.e. the index corresponding to x. |
---|
959 | \n |
---|
960 | \a arg[1] |
---|
961 | index corresponding to the right operand for this operator; |
---|
962 | i.e. the index corresponding to y. |
---|
963 | |
---|
964 | \param parameter |
---|
965 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
966 | is the value corresponding to x. |
---|
967 | \n |
---|
968 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
969 | is the value corresponding to y. |
---|
970 | |
---|
971 | \param cap_order |
---|
972 | maximum number of orders that will fit in the \c taylor array. |
---|
973 | |
---|
974 | \param taylor |
---|
975 | \b Input: If x is a variable, |
---|
976 | <code>taylor [ arg[0] * cap_order + k ]</code> |
---|
977 | for k = 0 , ... , q, |
---|
978 | is the k-th order Taylor coefficient corresponding to x. |
---|
979 | \n |
---|
980 | \b Input: If y is a variable, |
---|
981 | <code>taylor [ arg[1] * cap_order + k ]</code> |
---|
982 | for k = 0 , ... , q |
---|
983 | is the k-th order Taylor coefficient corresponding to y. |
---|
984 | \n |
---|
985 | \b Input: <code>taylor [ (i_z-2+j) * cap_order + k ]</code>, |
---|
986 | for j = 0, 1, 2 , for k = 0 , ... , p-1, |
---|
987 | is the k-th order Taylor coefficient corresponding to z_j. |
---|
988 | \n |
---|
989 | \b Output: <code>taylor [ (i_z-2+j) * cap_order + k ]</code>, |
---|
990 | is the k-th order Taylor coefficient corresponding to z_j. |
---|
991 | |
---|
992 | \par Checked Assertions |
---|
993 | \li NumArg(op) == 2 |
---|
994 | \li NumRes(op) == 3 |
---|
995 | \li If x is a variable, arg[0] < i_z - 2 |
---|
996 | \li If y is a variable, arg[1] < i_z - 2 |
---|
997 | \li q < cap_order |
---|
998 | \li p <= q |
---|
999 | */ |
---|
1000 | template <class Base> |
---|
1001 | inline void forward_pow_op( |
---|
1002 | size_t p , |
---|
1003 | size_t q , |
---|
1004 | size_t i_z , |
---|
1005 | const addr_t* arg , |
---|
1006 | const Base* parameter , |
---|
1007 | size_t cap_order , |
---|
1008 | Base* taylor ) |
---|
1009 | { |
---|
1010 | // This routine is only for documentaiton, it should not be used |
---|
1011 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
1012 | } |
---|
1013 | /*! |
---|
1014 | Prototype for multiple direction forward mode z = pow(x, y) (not used). |
---|
1015 | |
---|
1016 | \tparam Base |
---|
1017 | base type for the operator; i.e., this operation was recorded |
---|
1018 | using AD< \a Base > and computations by this routine are done using type |
---|
1019 | \a Base. |
---|
1020 | |
---|
1021 | \param q |
---|
1022 | order of the Taylor coefficient that we are computing. |
---|
1023 | |
---|
1024 | \param r |
---|
1025 | is the number of Taylor coefficient directions that we are computing |
---|
1026 | |
---|
1027 | \param i_z |
---|
1028 | variable index corresponding to the last (primary) result for this operation; |
---|
1029 | i.e. the row index in \a taylor corresponding to z. |
---|
1030 | Note that there are three results for this operation, |
---|
1031 | below they are referred to as z_0, z_1, z_2 and correspond to |
---|
1032 | \verbatim |
---|
1033 | z_0 = log(x) |
---|
1034 | z_1 = z0 * y |
---|
1035 | z_2 = exp(z1) |
---|
1036 | \endverbatim |
---|
1037 | It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). |
---|
1038 | |
---|
1039 | \param arg |
---|
1040 | \a arg[0] |
---|
1041 | index corresponding to the left operand for this operator; |
---|
1042 | i.e. the index corresponding to x. |
---|
1043 | \n |
---|
1044 | \a arg[1] |
---|
1045 | index corresponding to the right operand for this operator; |
---|
1046 | i.e. the index corresponding to y. |
---|
1047 | |
---|
1048 | \param parameter |
---|
1049 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
1050 | is the value corresponding to x. |
---|
1051 | \n |
---|
1052 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
1053 | is the value corresponding to y. |
---|
1054 | |
---|
1055 | \param cap_order |
---|
1056 | maximum number of orders that will fit in the \c taylor array. |
---|
1057 | |
---|
1058 | \par tpv |
---|
1059 | We use the notation |
---|
1060 | <code>tpv = (cap_order-1) * r + 1</code> |
---|
1061 | which is the number of Taylor coefficients per variable |
---|
1062 | |
---|
1063 | \param taylor |
---|
1064 | \b Input: If x is a variable, |
---|
1065 | <code>taylor [ arg[0] * tpv + 0 ]</code> |
---|
1066 | is the zero order coefficient corresponding to x and |
---|
1067 | <code>taylor [ arg[0] * tpv + (k-1)*r+1+ell ]</code> |
---|
1068 | for k = 1 , ... , q, |
---|
1069 | ell = 0 , ... , r-1, |
---|
1070 | is the k-th order Taylor coefficient corresponding to x |
---|
1071 | for the ell-th direction. |
---|
1072 | \n |
---|
1073 | \n |
---|
1074 | \b Input: If y is a variable, |
---|
1075 | <code>taylor [ arg[1] * tpv + 0 ]</code> |
---|
1076 | is the zero order coefficient corresponding to y and |
---|
1077 | <code>taylor [ arg[1] * tpv + (k-1)*r+1+ell ]</code> |
---|
1078 | for k = 1 , ... , q, |
---|
1079 | ell = 0 , ... , r-1, |
---|
1080 | is the k-th order Taylor coefficient corresponding to y |
---|
1081 | for the ell-th direction. |
---|
1082 | \n |
---|
1083 | \n |
---|
1084 | \b Input: |
---|
1085 | <code>taylor [ (i_z-2+j) * tpv + 0 ]</code>, |
---|
1086 | is the zero order coefficient corresponding to z_j and |
---|
1087 | <code>taylor [ (i_z-2+j) * tpv + (k-1)*r+1+ell ]</code>, |
---|
1088 | for j = 0, 1, 2 , k = 0 , ... , q-1, ell = 0, ... , r-1, |
---|
1089 | is the k-th order Taylor coefficient corresponding to z_j |
---|
1090 | for the ell-th direction. |
---|
1091 | \n |
---|
1092 | \n |
---|
1093 | \b Output: |
---|
1094 | <code>taylor [ (i_z-2+j) * tpv + (q-1)*r+1+ell ]</code>, |
---|
1095 | for j = 0, 1, 2 , ell = 0, ... , r-1, |
---|
1096 | is the q-th order Taylor coefficient corresponding to z_j |
---|
1097 | for the ell-th direction. |
---|
1098 | |
---|
1099 | \par Checked Assertions |
---|
1100 | \li NumArg(op) == 2 |
---|
1101 | \li NumRes(op) == 3 |
---|
1102 | \li If x is a variable, arg[0] < i_z - 2 |
---|
1103 | \li If y is a variable, arg[1] < i_z - 2 |
---|
1104 | \li 0 < q |
---|
1105 | \li q < cap_order |
---|
1106 | */ |
---|
1107 | template <class Base> |
---|
1108 | inline void forward_pow_op_dir( |
---|
1109 | size_t q , |
---|
1110 | size_t r , |
---|
1111 | size_t i_z , |
---|
1112 | const addr_t* arg , |
---|
1113 | const Base* parameter , |
---|
1114 | size_t cap_order , |
---|
1115 | Base* taylor ) |
---|
1116 | { |
---|
1117 | // This routine is only for documentaiton, it should not be used |
---|
1118 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
1119 | } |
---|
1120 | /*! |
---|
1121 | Prototype for zero order forward mode z = pow(x, y) (not used). |
---|
1122 | |
---|
1123 | \tparam Base |
---|
1124 | base type for the operator; i.e., this operation was recorded |
---|
1125 | using AD< \a Base > and computations by this routine are done using type |
---|
1126 | \a Base. |
---|
1127 | |
---|
1128 | \param i_z |
---|
1129 | variable index corresponding to the last (primary) result for this operation; |
---|
1130 | i.e. the row index in \a taylor corresponding to z. |
---|
1131 | Note that there are three results for this operation, |
---|
1132 | below they are referred to as z_0, z_1, z_2 and correspond to |
---|
1133 | \verbatim |
---|
1134 | z_0 = log(x) |
---|
1135 | z_1 = z0 * y |
---|
1136 | z_2 = exp(z1) |
---|
1137 | \endverbatim |
---|
1138 | It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). |
---|
1139 | |
---|
1140 | \param arg |
---|
1141 | \a arg[0] |
---|
1142 | index corresponding to the left operand for this operator; |
---|
1143 | i.e. the index corresponding to x. |
---|
1144 | \n |
---|
1145 | \a arg[1] |
---|
1146 | index corresponding to the right operand for this operator; |
---|
1147 | i.e. the index corresponding to y. |
---|
1148 | |
---|
1149 | \param parameter |
---|
1150 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
1151 | is the value corresponding to x. |
---|
1152 | \n |
---|
1153 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
1154 | is the value corresponding to y. |
---|
1155 | |
---|
1156 | \param cap_order |
---|
1157 | maximum number of orders that will fit in the \c taylor array. |
---|
1158 | |
---|
1159 | \param taylor |
---|
1160 | \b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] |
---|
1161 | is the zero order Taylor coefficient corresponding to x. |
---|
1162 | \n |
---|
1163 | \b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] |
---|
1164 | is the k-th order Taylor coefficient corresponding to y. |
---|
1165 | \n |
---|
1166 | \b Output: \a taylor [ \a (i_z - 2 + j) * \a cap_order + 0 ] |
---|
1167 | is the zero order Taylor coefficient corresponding to z_j. |
---|
1168 | |
---|
1169 | \par Checked Assertions |
---|
1170 | \li NumArg(op) == 2 |
---|
1171 | \li NumRes(op) == 3 |
---|
1172 | \li If x is a variable, \a arg[0] < \a i_z - 2 |
---|
1173 | \li If y is a variable, \a arg[1] < \a i_z - 2 |
---|
1174 | */ |
---|
1175 | template <class Base> |
---|
1176 | inline void forward_pow_op_0( |
---|
1177 | size_t i_z , |
---|
1178 | const addr_t* arg , |
---|
1179 | const Base* parameter , |
---|
1180 | size_t cap_order , |
---|
1181 | Base* taylor ) |
---|
1182 | { |
---|
1183 | // This routine is only for documentaiton, it should not be used |
---|
1184 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
1185 | } |
---|
1186 | /*! |
---|
1187 | Prototype for reverse mode z = pow(x, y) (not used). |
---|
1188 | |
---|
1189 | This routine is given the partial derivatives of a function |
---|
1190 | G( z , y , x , w , ... ) |
---|
1191 | and it uses them to compute the partial derivatives of |
---|
1192 | \verbatim |
---|
1193 | H( y , x , w , u , ... ) = G[ pow(x , y) , y , x , w , u , ... ] |
---|
1194 | \endverbatim |
---|
1195 | |
---|
1196 | \tparam Base |
---|
1197 | base type for the operator; i.e., this operation was recorded |
---|
1198 | using AD< \a Base > and computations by this routine are done using type |
---|
1199 | \a Base . |
---|
1200 | |
---|
1201 | \param d |
---|
1202 | highest order Taylor coefficient that |
---|
1203 | we are computing the partial derivatives with respect to. |
---|
1204 | |
---|
1205 | \param i_z |
---|
1206 | variable index corresponding to the last (primary) result for this operation; |
---|
1207 | i.e. the row index in \a taylor corresponding to z. |
---|
1208 | Note that there are three results for this operation, |
---|
1209 | below they are referred to as z_0, z_1, z_2 and correspond to |
---|
1210 | \verbatim |
---|
1211 | z_0 = log(x) |
---|
1212 | z_1 = z0 * y |
---|
1213 | z_2 = exp(z1) |
---|
1214 | \endverbatim |
---|
1215 | It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). |
---|
1216 | |
---|
1217 | \param arg |
---|
1218 | \a arg[0] |
---|
1219 | index corresponding to the left operand for this operator; |
---|
1220 | i.e. the index corresponding to x. |
---|
1221 | \n |
---|
1222 | \a arg[1] |
---|
1223 | index corresponding to the right operand for this operator; |
---|
1224 | i.e. the index corresponding to y. |
---|
1225 | |
---|
1226 | \param parameter |
---|
1227 | If x is a parameter, \a parameter [ \a arg[0] ] |
---|
1228 | is the value corresponding to x. |
---|
1229 | \n |
---|
1230 | If y is a parameter, \a parameter [ \a arg[1] ] |
---|
1231 | is the value corresponding to y. |
---|
1232 | |
---|
1233 | \param cap_order |
---|
1234 | maximum number of orders that will fit in the \c taylor array. |
---|
1235 | |
---|
1236 | \param taylor |
---|
1237 | \a taylor [ \a (i_z - 2 + j) * \a cap_order + k ] |
---|
1238 | for j = 0, 1, 2 and k = 0 , ... , \a d |
---|
1239 | is the k-th order Taylor coefficient corresponding to z_j. |
---|
1240 | \n |
---|
1241 | If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] |
---|
1242 | for k = 0 , ... , \a d |
---|
1243 | is the k-th order Taylor coefficient corresponding to x. |
---|
1244 | \n |
---|
1245 | If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] |
---|
1246 | for k = 0 , ... , \a d |
---|
1247 | is the k-th order Taylor coefficient corresponding to y. |
---|
1248 | |
---|
1249 | \param nc_partial |
---|
1250 | number of colums in the matrix containing all the partial derivatives. |
---|
1251 | |
---|
1252 | \param partial |
---|
1253 | \b Input: \a partial [ \a (i_z - 2 + j) * \a nc_partial + k ] |
---|
1254 | for j = 0, 1, 2, and k = 0 , ... , \a d |
---|
1255 | is the partial derivative of |
---|
1256 | G( z , y , x , w , u , ... ) |
---|
1257 | with respect to the k-th order Taylor coefficient for z_j. |
---|
1258 | \n |
---|
1259 | \b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] |
---|
1260 | for k = 0 , ... , \a d |
---|
1261 | is the partial derivative of G( z , y , x , w , u , ... ) with respect to |
---|
1262 | the k-th order Taylor coefficient for x. |
---|
1263 | \n |
---|
1264 | \b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] |
---|
1265 | for k = 0 , ... , \a d |
---|
1266 | is the partial derivative of G( z , x , w , u , ... ) with respect to |
---|
1267 | the k-th order Taylor coefficient for the auxillary variable y. |
---|
1268 | \n |
---|
1269 | \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] |
---|
1270 | for k = 0 , ... , \a d |
---|
1271 | is the partial derivative of H( y , x , w , u , ... ) with respect to |
---|
1272 | the k-th order Taylor coefficient for x. |
---|
1273 | \n |
---|
1274 | \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] |
---|
1275 | for k = 0 , ... , \a d |
---|
1276 | is the partial derivative of H( y , x , w , u , ... ) with respect to |
---|
1277 | the k-th order Taylor coefficient for y. |
---|
1278 | \n |
---|
1279 | \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] |
---|
1280 | for j = 0 , 1 , 2 and for k = 0 , ... , \a d |
---|
1281 | may be used as work space; i.e., may change in an unspecified manner. |
---|
1282 | |
---|
1283 | \par Checked Assumptions |
---|
1284 | \li NumArg(op) == 2 |
---|
1285 | \li NumRes(op) == 3 |
---|
1286 | \li \a If x is a variable, arg[0] < \a i_z - 2 |
---|
1287 | \li \a If y is a variable, arg[1] < \a i_z - 2 |
---|
1288 | \li \a d < \a cap_order |
---|
1289 | \li \a d < \a nc_partial |
---|
1290 | */ |
---|
1291 | template <class Base> |
---|
1292 | inline void reverse_pow_op( |
---|
1293 | size_t d , |
---|
1294 | size_t i_z , |
---|
1295 | addr_t* arg , |
---|
1296 | const Base* parameter , |
---|
1297 | size_t cap_order , |
---|
1298 | const Base* taylor , |
---|
1299 | size_t nc_partial , |
---|
1300 | Base* partial ) |
---|
1301 | { |
---|
1302 | // This routine is only for documentaiton, it should not be used |
---|
1303 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
1304 | } |
---|
1305 | |
---|
1306 | // ==================== Sparsity Calculations ============================== |
---|
1307 | /*! |
---|
1308 | Prototype for reverse mode Hessian sparsity unary operators. |
---|
1309 | |
---|
1310 | This routine is given the forward mode Jacobian sparsity patterns for x. |
---|
1311 | It is also given the reverse mode dependence of G on z. |
---|
1312 | In addition, it is given the revese mode Hessian sparsity |
---|
1313 | for the quanity of interest G(z , y , ... ) |
---|
1314 | and it uses them to compute the sparsity patterns for |
---|
1315 | \verbatim |
---|
1316 | H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] |
---|
1317 | \endverbatim |
---|
1318 | |
---|
1319 | \tparam Vector_set |
---|
1320 | is the type used for vectors of sets. It can be either |
---|
1321 | \c sparse_pack, \c sparse_set, or \c sparse_list. |
---|
1322 | |
---|
1323 | \param i_z |
---|
1324 | variable index corresponding to the result for this operation; |
---|
1325 | i.e. the row index in sparsity corresponding to z. |
---|
1326 | |
---|
1327 | \param i_x |
---|
1328 | variable index corresponding to the argument for this operator; |
---|
1329 | i.e. the row index in sparsity corresponding to x. |
---|
1330 | |
---|
1331 | \param rev_jacobian |
---|
1332 | \a rev_jacobian[i_z] |
---|
1333 | is all false (true) if the Jacobian of G with respect to z must be zero |
---|
1334 | (may be non-zero). |
---|
1335 | \n |
---|
1336 | \n |
---|
1337 | \a rev_jacobian[i_x] |
---|
1338 | is all false (true) if the Jacobian with respect to x must be zero |
---|
1339 | (may be non-zero). |
---|
1340 | On input, it corresponds to the function G, |
---|
1341 | and on output it corresponds to the function H. |
---|
1342 | |
---|
1343 | \param for_jac_sparsity |
---|
1344 | The set with index \a i_x in for_jac_sparsity |
---|
1345 | is the forward mode Jacobian sparsity pattern for the variable x. |
---|
1346 | |
---|
1347 | \param rev_hes_sparsity |
---|
1348 | The set with index \a i_z in in \a rev_hes_sparsity |
---|
1349 | is the Hessian sparsity pattern for the fucntion G |
---|
1350 | where one of the partials derivative is with respect to z. |
---|
1351 | \n |
---|
1352 | \n |
---|
1353 | The set with index \a i_x in \a rev_hes_sparsity |
---|
1354 | is the Hessian sparsity pattern |
---|
1355 | where one of the partials derivative is with respect to x. |
---|
1356 | On input, it corresponds to the function G, |
---|
1357 | and on output it corresponds to the function H. |
---|
1358 | |
---|
1359 | \par Checked Assertions: |
---|
1360 | \li \a i_x < \a i_z |
---|
1361 | */ |
---|
1362 | |
---|
1363 | template <class Vector_set> |
---|
1364 | inline void reverse_sparse_hessian_unary_op( |
---|
1365 | size_t i_z , |
---|
1366 | size_t i_x , |
---|
1367 | bool* rev_jacobian , |
---|
1368 | Vector_set& for_jac_sparsity , |
---|
1369 | Vector_set& rev_hes_sparsity ) |
---|
1370 | { |
---|
1371 | // This routine is only for documentaiton, it should not be used |
---|
1372 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
1373 | } |
---|
1374 | |
---|
1375 | /*! |
---|
1376 | Prototype for reverse mode Hessian sparsity binary operators. |
---|
1377 | |
---|
1378 | This routine is given the sparsity patterns the Hessian |
---|
1379 | of a function G(z, y, x, ... ) |
---|
1380 | and it uses them to compute the sparsity patterns for the Hessian of |
---|
1381 | \verbatim |
---|
1382 | H( y, x, w , u , ... ) = G[ z(x,y) , y , x , w , u , ... ] |
---|
1383 | \endverbatim |
---|
1384 | |
---|
1385 | \tparam Vector_set |
---|
1386 | is the type used for vectors of sets. It can be either |
---|
1387 | \c sparse_pack, \c sparse_set, or \c sparse_list. |
---|
1388 | |
---|
1389 | \param i_z |
---|
1390 | variable index corresponding to the result for this operation; |
---|
1391 | i.e. the row index in sparsity corresponding to z. |
---|
1392 | |
---|
1393 | \param arg |
---|
1394 | \a arg[0] |
---|
1395 | variable index corresponding to the left operand for this operator; |
---|
1396 | i.e. the set with index \a arg[0] in \a var_sparsity |
---|
1397 | is the spasity pattern correspoding to x. |
---|
1398 | \n |
---|
1399 | \n arg[1] |
---|
1400 | variable index corresponding to the right operand for this operator; |
---|
1401 | i.e. the row index in sparsity patterns corresponding to y. |
---|
1402 | |
---|
1403 | \param jac_reverse |
---|
1404 | \a jac_reverse[i_z] |
---|
1405 | is false (true) if the Jacobian of G with respect to z is always zero |
---|
1406 | (may be non-zero). |
---|
1407 | \n |
---|
1408 | \n |
---|
1409 | \a jac_reverse[ \a arg[0] ] |
---|
1410 | is false (true) if the Jacobian with respect to x is always zero |
---|
1411 | (may be non-zero). |
---|
1412 | On input, it corresponds to the function G, |
---|
1413 | and on output it corresponds to the function H. |
---|
1414 | \n |
---|
1415 | \n |
---|
1416 | \a jac_reverse[ \a arg[1] ] |
---|
1417 | is false (true) if the Jacobian with respect to y is always zero |
---|
1418 | (may be non-zero). |
---|
1419 | On input, it corresponds to the function G, |
---|
1420 | and on output it corresponds to the function H. |
---|
1421 | |
---|
1422 | \param for_jac_sparsity |
---|
1423 | The set with index \a arg[0] in \a for_jac_sparsity for the |
---|
1424 | is the forward Jacobian sparsity pattern for x. |
---|
1425 | \n |
---|
1426 | \n |
---|
1427 | The set with index \a arg[1] in \a for_jac_sparsity |
---|
1428 | is the forward sparsity pattern for y. |
---|
1429 | |
---|
1430 | \param rev_hes_sparsity |
---|
1431 | The set wiht index \a i_x in \a rev_hes_sparsity |
---|
1432 | is the Hessian sparsity pattern for the function G |
---|
1433 | where one of the partial derivatives is with respect to z. |
---|
1434 | \n |
---|
1435 | \n |
---|
1436 | The set with index \a arg[0] in \a rev_hes_sparsity |
---|
1437 | is the Hessian sparsity pattern where one of the |
---|
1438 | partial derivatives is with respect to x. |
---|
1439 | On input, it corresponds to the function G, |
---|
1440 | and on output it correspondst to H. |
---|
1441 | \n |
---|
1442 | \n |
---|
1443 | The set with index \a arg[1] in \a rev_hes_sparsity |
---|
1444 | is the Hessian sparsity pattern where one of the |
---|
1445 | partial derivatives is with respect to y. |
---|
1446 | On input, it corresponds to the function G, |
---|
1447 | and on output it correspondst to H. |
---|
1448 | |
---|
1449 | \par Checked Assertions: |
---|
1450 | \li \a arg[0] < \a i_z |
---|
1451 | \li \a arg[1] < \a i_z |
---|
1452 | */ |
---|
1453 | template <class Vector_set> |
---|
1454 | inline void reverse_sparse_hessian_binary_op( |
---|
1455 | size_t i_z , |
---|
1456 | const addr_t* arg , |
---|
1457 | bool* jac_reverse , |
---|
1458 | Vector_set& for_jac_sparsity , |
---|
1459 | Vector_set& rev_hes_sparsity ) |
---|
1460 | { |
---|
1461 | // This routine is only for documentaiton, it should not be used |
---|
1462 | CPPAD_ASSERT_UNKNOWN( false ); |
---|
1463 | } |
---|
1464 | |
---|
1465 | |
---|
1466 | } // END_CPPAD_NAMESPACE |
---|
1467 | # endif |
---|