CppAD: A C++ Algorithmic Differentiation Package
20130918
|
00001 /* $Id$ */ 00002 # ifndef CPPAD_PROTOTYPE_OP_INCLUDED 00003 # define CPPAD_PROTOTYPE_OP_INCLUDED 00004 00005 /* -------------------------------------------------------------------------- 00006 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell 00007 00008 CppAD is distributed under multiple licenses. This distribution is under 00009 the terms of the 00010 Eclipse Public License Version 1.0. 00011 00012 A copy of this license is included in the COPYING file of this distribution. 00013 Please visit http://www.coin-or.org/CppAD/ for information on other licenses. 00014 -------------------------------------------------------------------------- */ 00015 00016 00017 namespace CppAD { // BEGIN_CPPAD_NAMESPACE 00018 /*! 00019 \file prototype_op.hpp 00020 Documentation for generic cases (these generic cases are never used). 00021 */ 00022 00023 // ==================== Unary operators with one result ==================== 00024 00025 00026 /*! 00027 Prototype for forward mode unary operator with one result (not used). 00028 00029 \tparam Base 00030 base type for the operator; i.e., this operation was recorded 00031 using AD< \a Base > and computations by this routine are done using type 00032 \a Base. 00033 00034 \param p 00035 lowest order of the Taylor coefficient that we are computing. 00036 00037 \param q 00038 highest order of the Taylor coefficient that we are computing. 00039 00040 \param i_z 00041 variable index corresponding to the result for this operation; 00042 i.e. the row index in \a taylor corresponding to z. 00043 00044 \param i_x 00045 variable index corresponding to the argument for this operator; 00046 i.e. the row index in \a taylor corresponding to x. 00047 00048 \param nc_taylor 00049 number of colums in the matrix containing all the Taylor coefficients. 00050 00051 \param taylor 00052 \b Input: <code>taylor [ i_x * nc_taylor + k ]</code>, 00053 for k = 0 , ... , q, 00054 is the k-th order Taylor coefficient corresponding to x. 00055 \n 00056 \b Input: <code>taylor [ i_z * nc_taylor + k ]</code>, 00057 for k = 0 , ... , p-1, 00058 is the k-th order Taylor coefficient corresponding to z. 00059 \n 00060 \b Output: <code>taylor [ i_z * nc_taylor + k ]</code>, 00061 for k = p , ... , q, 00062 is the k-th order Taylor coefficient corresponding to z. 00063 00064 \par Checked Assertions 00065 \li NumArg(op) == 1 00066 \li NumRes(op) == 1 00067 \li i_x < i_z 00068 \li q < nc_taylor 00069 \li p <= q 00070 */ 00071 template <class Base> 00072 inline void forward_unary1_op( 00073 size_t p , 00074 size_t q , 00075 size_t i_z , 00076 size_t i_x , 00077 size_t nc_taylor , 00078 Base* taylor ) 00079 { 00080 // This routine is only for documentaiton, it should not be used 00081 CPPAD_ASSERT_UNKNOWN( false ); 00082 } 00083 00084 /*! 00085 Prototype for zero order forward mode unary operator with one result (not used). 00086 \tparam Base 00087 base type for the operator; i.e., this operation was recorded 00088 using AD< \a Base > and computations by this routine are done using type 00089 \a Base . 00090 00091 \param i_z 00092 variable index corresponding to the result for this operation; 00093 i.e. the row index in \a taylor corresponding to z. 00094 00095 \param i_x 00096 variable index corresponding to the argument for this operator; 00097 i.e. the row index in \a taylor corresponding to x. 00098 00099 \param nc_taylor 00100 number of colums in the matrix containing all the Taylor coefficients. 00101 00102 \param taylor 00103 \b Input: \a taylor [ \a i_x * \a nc_taylor + 0 ] 00104 is the zero order Taylor coefficient corresponding to x. 00105 \n 00106 \b Output: \a taylor [ \a i_z * \a nc_taylor + 0 ] 00107 is the zero order Taylor coefficient corresponding to z. 00108 00109 \par Checked Assertions 00110 \li NumArg(op) == 1 00111 \li NumRes(op) == 1 00112 \li \a i_x < \a i_z 00113 \li \a 0 < \a nc_taylor 00114 */ 00115 template <class Base> 00116 inline void forward_unary1_op_0( 00117 size_t i_z , 00118 size_t i_x , 00119 size_t nc_taylor , 00120 Base* taylor ) 00121 { 00122 // This routine is only for documentaiton, it should not be used 00123 CPPAD_ASSERT_UNKNOWN( false ); 00124 } 00125 00126 /*! 00127 Prototype for reverse mode unary operator with one result (not used). 00128 00129 This routine is given the partial derivatives of a function 00130 G(z , x , w, u ... ) 00131 and it uses them to compute the partial derivatives of 00132 \verbatim 00133 H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] 00134 \endverbatim 00135 00136 \tparam Base 00137 base type for the operator; i.e., this operation was recorded 00138 using AD< \a Base > and computations by this routine are done using type 00139 \a Base . 00140 00141 \param d 00142 highest order Taylor coefficient that 00143 we are computing the partial derivatives with respect to. 00144 00145 \param i_z 00146 variable index corresponding to the result for this operation; 00147 i.e. the row index in \a taylor to z. 00148 00149 \param i_x 00150 variable index corresponding to the argument for this operation; 00151 i.e. the row index in \a taylor corresponding to x. 00152 00153 \param nc_taylor 00154 number of colums in the matrix containing all the Taylor coefficients. 00155 00156 \param taylor 00157 \a taylor [ \a i_x * \a nc_taylor + k ] 00158 for k = 0 , ... , \a d 00159 is the k-th order Taylor coefficient corresponding to x. 00160 \n 00161 \a taylor [ \a i_z * \a nc_taylor + k ] 00162 for k = 0 , ... , \a d 00163 is the k-th order Taylor coefficient corresponding to z. 00164 00165 \param nc_partial 00166 number of colums in the matrix containing all the partial derivatives. 00167 00168 \param partial 00169 \b Input: \a partial [ \a i_x * \a nc_partial + k ] 00170 for k = 0 , ... , \a d 00171 is the partial derivative of G( z , x , w , u , ... ) with respect to 00172 the k-th order Taylor coefficient for x. 00173 \n 00174 \b Input: \a partial [ \a i_z * \a nc_partial + k ] 00175 for k = 0 , ... , \a d 00176 is the partial derivative of G( z , x , w , u , ... ) with respect to 00177 the k-th order Taylor coefficient for z. 00178 \n 00179 \b Output: \a partial [ \a i_x * \a nc_partial + k ] 00180 for k = 0 , ... , \a d 00181 is the partial derivative of H( x , w , u , ... ) with respect to 00182 the k-th order Taylor coefficient for x. 00183 \n 00184 \b Output: \a partial [ \a i_z * \a nc_partial + k ] 00185 for k = 0 , ... , \a d 00186 may be used as work space; i.e., may change in an unspecified manner. 00187 00188 00189 \par Checked Assumptions 00190 \li NumArg(op) == 1 00191 \li NumRes(op) == 1 00192 \li \a i_x < \a i_z 00193 \li \a d < \a nc_taylor 00194 \li \a d < \a nc_partial 00195 */ 00196 template <class Base> 00197 inline void reverse_unary1_op( 00198 size_t d , 00199 size_t i_z , 00200 size_t i_x , 00201 size_t nc_taylor , 00202 const Base* taylor , 00203 size_t nc_partial , 00204 Base* partial ) 00205 { 00206 // This routine is only for documentaiton, it should not be used 00207 CPPAD_ASSERT_UNKNOWN( false ); 00208 } 00209 00210 // ==================== Unary operators with two results ==================== 00211 00212 /*! 00213 Prototype for forward mode unary operator with two results (not used). 00214 00215 \tparam Base 00216 base type for the operator; i.e., this operation was recorded 00217 using AD< \a Base > and computations by this routine are done using type 00218 \a Base. 00219 00220 \param p 00221 lowest order of the Taylor coefficients that we are computing. 00222 00223 \param q 00224 highest order of the Taylor coefficients that we are computing. 00225 00226 \param i_z 00227 variable index corresponding to the last (primary) result for this operation; 00228 i.e. the row index in \a taylor corresponding to z. 00229 The auxillary result is called y has index \a i_z - 1. 00230 00231 \param i_x 00232 variable index corresponding to the argument for this operator; 00233 i.e. the row index in \a taylor corresponding to x. 00234 00235 \param nc_taylor 00236 number of colums in the matrix containing all the Taylor coefficients. 00237 00238 \param taylor 00239 \b Input: <code>taylor [ i_x * nc_taylor + k ]</code> 00240 for k = 0 , ... , q, 00241 is the k-th order Taylor coefficient corresponding to x. 00242 \n 00243 \b Input: <code>taylor [ i_z * nc_taylor + k ]</code> 00244 for k = 0 , ... , p - 1, 00245 is the k-th order Taylor coefficient corresponding to z. 00246 \n 00247 \b Input: <code>taylor [ ( i_z - 1) * nc_taylor + k ]</code> 00248 for k = 0 , ... , p-1, 00249 is the k-th order Taylor coefficient corresponding to the auxillary result y. 00250 \n 00251 \b Output: <code>taylor [ i_z * nc_taylor + k ]</code>, 00252 for k = p , ... , q, 00253 is the k-th order Taylor coefficient corresponding to z. 00254 \n 00255 \b Output: <code>taylor [ ( i_z - 1 ) * nc_taylor + k ]</code>, 00256 for k = p , ... , q, 00257 is the k-th order Taylor coefficient corresponding to 00258 the autillary result y. 00259 00260 \par Checked Assertions 00261 \li NumArg(op) == 1 00262 \li NumRes(op) == 2 00263 \li i_x + 1 < i_z 00264 \li q < nc_taylor 00265 \li p <= q 00266 */ 00267 template <class Base> 00268 inline void forward_unary2_op( 00269 size_t p , 00270 size_t q , 00271 size_t i_z , 00272 size_t i_x , 00273 size_t nc_taylor , 00274 Base* taylor ) 00275 { 00276 // This routine is only for documentaiton, it should not be used 00277 CPPAD_ASSERT_UNKNOWN( false ); 00278 } 00279 00280 /*! 00281 Prototype for zero order forward mode unary operator with two results (not used). 00282 \tparam Base 00283 base type for the operator; i.e., this operation was recorded 00284 using AD< \a Base > and computations by this routine are done using type 00285 \a Base . 00286 00287 \param i_z 00288 variable index corresponding to the last (primary) result for this operation; 00289 i.e. the row index in \a taylor corresponding to z. 00290 The auxillary result is called y and has index \a i_z - 1. 00291 00292 \param i_x 00293 variable index corresponding to the argument for this operator; 00294 i.e. the row index in \a taylor corresponding to x. 00295 00296 \param nc_taylor 00297 number of colums in the matrix containing all the Taylor coefficients. 00298 00299 \param taylor 00300 \b Input: \a taylor [ \a i_x * \a nc_taylor + 0 ] 00301 is the zero order Taylor coefficient corresponding to x. 00302 \n 00303 \b Output: \a taylor [ \a i_z * \a nc_taylor + 0 ] 00304 is the zero order Taylor coefficient corresponding to z. 00305 \n 00306 \b Output: \a taylor [ ( \a i_z - 1 ) * \a nc_taylor + j ] 00307 is the j-th order Taylor coefficient corresponding to 00308 the autillary result y. 00309 00310 \par Checked Assertions 00311 \li NumArg(op) == 1 00312 \li NumRes(op) == 2 00313 \li \a i_x + 1 < \a i_z 00314 \li \a j < \a nc_taylor 00315 */ 00316 template <class Base> 00317 inline void forward_unary2_op_0( 00318 size_t i_z , 00319 size_t i_x , 00320 size_t nc_taylor , 00321 Base* taylor ) 00322 { 00323 // This routine is only for documentaiton, it should not be used 00324 CPPAD_ASSERT_UNKNOWN( false ); 00325 } 00326 00327 /*! 00328 Prototype for reverse mode unary operator with two results (not used). 00329 00330 This routine is given the partial derivatives of a function 00331 G( z , y , x , w , ... ) 00332 and it uses them to compute the partial derivatives of 00333 \verbatim 00334 H( x , w , u , ... ) = G[ z(x) , y(x), x , w , u , ... ] 00335 \endverbatim 00336 00337 \tparam Base 00338 base type for the operator; i.e., this operation was recorded 00339 using AD< \a Base > and computations by this routine are done using type 00340 \a Base . 00341 00342 \param d 00343 highest order Taylor coefficient that 00344 we are computing the partial derivatives with respect to. 00345 00346 \param i_z 00347 variable index corresponding to the last (primary) result for this operation; 00348 i.e. the row index in \a taylor to z. 00349 The auxillary result is called y and has index \a i_z - 1. 00350 00351 \param i_x 00352 variable index corresponding to the argument for this operation; 00353 i.e. the row index in \a taylor corresponding to x. 00354 00355 \param nc_taylor 00356 number of colums in the matrix containing all the Taylor coefficients. 00357 00358 \param taylor 00359 \a taylor [ \a i_x * \a nc_taylor + k ] 00360 for k = 0 , ... , \a d 00361 is the k-th order Taylor coefficient corresponding to x. 00362 \n 00363 \a taylor [ \a i_z * \a nc_taylor + k ] 00364 for k = 0 , ... , \a d 00365 is the k-th order Taylor coefficient corresponding to z. 00366 \n 00367 \a taylor [ ( \a i_z - 1) * \a nc_taylor + k ] 00368 for k = 0 , ... , \a d 00369 is the k-th order Taylor coefficient corresponding to 00370 the auxillary variable y. 00371 00372 \param nc_partial 00373 number of colums in the matrix containing all the partial derivatives. 00374 00375 \param partial 00376 \b Input: \a partial [ \a i_x * \a nc_partial + k ] 00377 for k = 0 , ... , \a d 00378 is the partial derivative of 00379 G( z , y , x , w , u , ... ) 00380 with respect to the k-th order Taylor coefficient for x. 00381 \n 00382 \b Input: \a partial [ \a i_z * \a nc_partial + k ] 00383 for k = 0 , ... , \a d 00384 is the partial derivative of G( z , y , x , w , u , ... ) with respect to 00385 the k-th order Taylor coefficient for z. 00386 \n 00387 \b Input: \a partial [ ( \a i_z - 1) * \a nc_partial + k ] 00388 for k = 0 , ... , \a d 00389 is the partial derivative of G( z , x , w , u , ... ) with respect to 00390 the k-th order Taylor coefficient for the auxillary variable y. 00391 \n 00392 \b Output: \a partial [ \a i_x * \a nc_partial + k ] 00393 for k = 0 , ... , \a d 00394 is the partial derivative of H( x , w , u , ... ) with respect to 00395 the k-th order Taylor coefficient for x. 00396 \n 00397 \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] 00398 for j = 0 , 1 , and for k = 0 , ... , \a d 00399 may be used as work space; i.e., may change in an unspecified manner. 00400 00401 00402 \par Checked Assumptions 00403 \li NumArg(op) == 1 00404 \li NumRes(op) == 2 00405 \li \a i_x + 1 < \a i_z 00406 \li \a d < \a nc_taylor 00407 \li \a d < \a nc_partial 00408 */ 00409 template <class Base> 00410 inline void reverse_unary2_op( 00411 size_t d , 00412 size_t i_z , 00413 size_t i_x , 00414 size_t nc_taylor , 00415 const Base* taylor , 00416 size_t nc_partial , 00417 Base* partial ) 00418 { 00419 // This routine is only for documentaiton, it should not be used 00420 CPPAD_ASSERT_UNKNOWN( false ); 00421 } 00422 // =================== Binary operators with one result ==================== 00423 00424 /*! 00425 Prototype forward mode x op y (not used) 00426 00427 \tparam Base 00428 base type for the operator; i.e., this operation was recorded 00429 using AD< \a Base > and computations by this routine are done using type 00430 \a Base. 00431 00432 \param p 00433 lowest order of the Taylor coefficient that we are computing. 00434 00435 \param q 00436 highest order of the Taylor coefficient that we are computing. 00437 00438 \param i_z 00439 variable index corresponding to the result for this operation; 00440 i.e. the row index in \a taylor corresponding to z. 00441 00442 \param arg 00443 \a arg[0] 00444 index corresponding to the left operand for this operator; 00445 i.e. the index corresponding to x. 00446 \n 00447 \a arg[1] 00448 index corresponding to the right operand for this operator; 00449 i.e. the index corresponding to y. 00450 00451 \param parameter 00452 If x is a parameter, \a parameter [ \a arg[0] ] 00453 is the value corresponding to x. 00454 \n 00455 If y is a parameter, \a parameter [ \a arg[1] ] 00456 is the value corresponding to y. 00457 00458 \param nc_taylor 00459 number of colums in the matrix containing all the Taylor coefficients. 00460 00461 \param taylor 00462 \b Input: If x is a variable, 00463 <code>taylor [ arg[0] * nc_taylor + k ]</code>, 00464 for k = 0 , ... , q, 00465 is the k-th order Taylor coefficient corresponding to x. 00466 \n 00467 \b Input: If y is a variable, 00468 <code>taylor [ arg[1] * nc_taylor + k ]</code>, 00469 for k = 0 , ... , q, 00470 is the k-th order Taylor coefficient corresponding to y. 00471 \n 00472 \b Input: <code>taylor [ i_z * nc_taylor + k ]</code>, 00473 for k = 0 , ... , p-1, 00474 is the k-th order Taylor coefficient corresponding to z. 00475 \n 00476 \b Output: <code>taylor [ i_z * nc_taylor + k ]</code>, 00477 for k = p, ... , q, 00478 is the k-th order Taylor coefficient corresponding to z. 00479 00480 \par Checked Assertions 00481 \li NumArg(op) == 2 00482 \li NumRes(op) == 1 00483 \li If x is a variable, arg[0] < i_z 00484 \li If y is a variable, arg[1] < i_z 00485 \li q < nc_taylor 00486 \li p <= q 00487 */ 00488 template <class Base> 00489 inline void forward_binary_op( 00490 size_t p , 00491 size_t q , 00492 size_t i_z , 00493 const addr_t* arg , 00494 const Base* parameter , 00495 size_t nc_taylor , 00496 Base* taylor ) 00497 { 00498 // This routine is only for documentaiton, it should not be used 00499 CPPAD_ASSERT_UNKNOWN( false ); 00500 } 00501 00502 00503 /*! 00504 Prototype zero order forward mode x op y (not used) 00505 00506 \tparam Base 00507 base type for the operator; i.e., this operation was recorded 00508 using AD< \a Base > and computations by this routine are done using type 00509 \a Base. 00510 00511 \param i_z 00512 variable index corresponding to the result for this operation; 00513 i.e. the row index in \a taylor corresponding to z. 00514 00515 \param arg 00516 \a arg[0] 00517 index corresponding to the left operand for this operator; 00518 i.e. the index corresponding to x. 00519 \n 00520 \a arg[1] 00521 index corresponding to the right operand for this operator; 00522 i.e. the index corresponding to y. 00523 00524 \param parameter 00525 If x is a parameter, \a parameter [ \a arg[0] ] 00526 is the value corresponding to x. 00527 \n 00528 If y is a parameter, \a parameter [ \a arg[1] ] 00529 is the value corresponding to y. 00530 00531 \param nc_taylor 00532 number of colums in the matrix containing all the Taylor coefficients. 00533 00534 \param taylor 00535 \b Input: If x is a variable, \a taylor [ \a arg[0] * \a nc_taylor + 0 ] 00536 is the zero order Taylor coefficient corresponding to x. 00537 \n 00538 \b Input: If y is a variable, \a taylor [ \a arg[1] * \a nc_taylor + 0 ] 00539 is the zero order Taylor coefficient corresponding to y. 00540 \n 00541 \b Output: \a taylor [ \a i_z * \a nc_taylor + 0 ] 00542 is the zero order Taylor coefficient corresponding to z. 00543 00544 \par Checked Assertions 00545 \li NumArg(op) == 2 00546 \li NumRes(op) == 1 00547 \li If x is a variable, \a arg[0] < \a i_z 00548 \li If y is a variable, \a arg[1] < \a i_z 00549 */ 00550 template <class Base> 00551 inline void forward_binary_op_0( 00552 size_t i_z , 00553 const addr_t* arg , 00554 const Base* parameter , 00555 size_t nc_taylor , 00556 Base* taylor ) 00557 { 00558 // This routine is only for documentaiton, it should not be used 00559 CPPAD_ASSERT_UNKNOWN( false ); 00560 } 00561 00562 /*! 00563 Prototype for reverse mode binary operator x op y (not used). 00564 00565 This routine is given the partial derivatives of a function 00566 G( z , y , x , w , ... ) 00567 and it uses them to compute the partial derivatives of 00568 \verbatim 00569 H( y , x , w , u , ... ) = G[ z(x , y) , y , x , w , u , ... ] 00570 \endverbatim 00571 00572 \tparam Base 00573 base type for the operator; i.e., this operation was recorded 00574 using AD< \a Base > and computations by this routine are done using type 00575 \a Base . 00576 00577 \param d 00578 highest order Taylor coefficient that 00579 we are computing the partial derivatives with respect to. 00580 00581 \param i_z 00582 variable index corresponding to the result for this operation; 00583 i.e. the row index in \a taylor corresponding to z. 00584 00585 \param arg 00586 \a arg[0] 00587 index corresponding to the left operand for this operator; 00588 i.e. the index corresponding to x. 00589 \n 00590 \a arg[1] 00591 index corresponding to the right operand for this operator; 00592 i.e. the index corresponding to y. 00593 00594 \param parameter 00595 If x is a parameter, \a parameter [ \a arg[0] ] 00596 is the value corresponding to x. 00597 \n 00598 If y is a parameter, \a parameter [ \a arg[1] ] 00599 is the value corresponding to y. 00600 00601 \param nc_taylor 00602 number of colums in the matrix containing all the Taylor coefficients. 00603 00604 \param taylor 00605 \a taylor [ \a i_z * \a nc_taylor + k ] 00606 for k = 0 , ... , \a d 00607 is the k-th order Taylor coefficient corresponding to z. 00608 \n 00609 If x is a variable, \a taylor [ \a arg[0] * \a nc_taylor + k ] 00610 for k = 0 , ... , \a d 00611 is the k-th order Taylor coefficient corresponding to x. 00612 \n 00613 If y is a variable, \a taylor [ \a arg[1] * \a nc_taylor + k ] 00614 for k = 0 , ... , \a d 00615 is the k-th order Taylor coefficient corresponding to y. 00616 00617 \param nc_partial 00618 number of colums in the matrix containing all the partial derivatives. 00619 00620 \param partial 00621 \b Input: \a partial [ \a i_z * \a nc_partial + k ] 00622 for k = 0 , ... , \a d 00623 is the partial derivative of 00624 G( z , y , x , w , u , ... ) 00625 with respect to the k-th order Taylor coefficient for z. 00626 \n 00627 \b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] 00628 for k = 0 , ... , \a d 00629 is the partial derivative of G( z , y , x , w , u , ... ) with respect to 00630 the k-th order Taylor coefficient for x. 00631 \n 00632 \b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] 00633 for k = 0 , ... , \a d 00634 is the partial derivative of G( z , x , w , u , ... ) with respect to 00635 the k-th order Taylor coefficient for the auxillary variable y. 00636 \n 00637 \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] 00638 for k = 0 , ... , \a d 00639 is the partial derivative of H( y , x , w , u , ... ) with respect to 00640 the k-th order Taylor coefficient for x. 00641 \n 00642 \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] 00643 for k = 0 , ... , \a d 00644 is the partial derivative of H( y , x , w , u , ... ) with respect to 00645 the k-th order Taylor coefficient for y. 00646 \n 00647 \b Output: \a partial [ \a i_z * \a nc_partial + k ] 00648 for k = 0 , ... , \a d 00649 may be used as work space; i.e., may change in an unspecified manner. 00650 00651 \par Checked Assumptions 00652 \li NumArg(op) == 2 00653 \li NumRes(op) == 1 00654 \li \a If x is a variable, arg[0] < \a i_z 00655 \li \a If y is a variable, arg[1] < \a i_z 00656 \li \a d < \a nc_taylor 00657 \li \a d < \a nc_partial 00658 */ 00659 template <class Base> 00660 inline void reverse_binary_op( 00661 size_t d , 00662 size_t i_z , 00663 addr_t* arg , 00664 const Base* parameter , 00665 size_t nc_taylor , 00666 const Base* taylor , 00667 size_t nc_partial , 00668 Base* partial ) 00669 { 00670 // This routine is only for documentaiton, it should not be used 00671 CPPAD_ASSERT_UNKNOWN( false ); 00672 } 00673 // ======================= Pow Function =================================== 00674 /*! 00675 Prototype for forward mode z = pow(x, y) (not used). 00676 00677 \tparam Base 00678 base type for the operator; i.e., this operation was recorded 00679 using AD< \a Base > and computations by this routine are done using type 00680 \a Base. 00681 00682 \param p 00683 lowest order of the Taylor coefficient that we are computing. 00684 00685 \param q 00686 highest order of the Taylor coefficient that we are computing. 00687 00688 \param i_z 00689 variable index corresponding to the last (primary) result for this operation; 00690 i.e. the row index in \a taylor corresponding to z. 00691 Note that there are three results for this operation, 00692 below they are referred to as z_0, z_1, z_2 and correspond to 00693 \verbatim 00694 z_0 = log(x) 00695 z_1 = z0 * y 00696 z_2 = exp(z1) 00697 \endverbatim 00698 It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). 00699 00700 \param arg 00701 \a arg[0] 00702 index corresponding to the left operand for this operator; 00703 i.e. the index corresponding to x. 00704 \n 00705 \a arg[1] 00706 index corresponding to the right operand for this operator; 00707 i.e. the index corresponding to y. 00708 00709 \param parameter 00710 If x is a parameter, \a parameter [ \a arg[0] ] 00711 is the value corresponding to x. 00712 \n 00713 If y is a parameter, \a parameter [ \a arg[1] ] 00714 is the value corresponding to y. 00715 00716 \param nc_taylor 00717 number of colums in the matrix containing all the Taylor coefficients. 00718 00719 \param taylor 00720 \b Input: If x is a variable, 00721 <code>taylor [ arg[0] * nc_taylor + k ]</code> 00722 for k = 0 , ... , q, 00723 is the k-th order Taylor coefficient corresponding to x. 00724 \n 00725 \b Input: If y is a variable, 00726 <code>taylor [ arg[1] * nc_taylor + k ]</code> 00727 for k = 0 , ... , q 00728 is the k-th order Taylor coefficient corresponding to y. 00729 \n 00730 \b Input: <code>taylor [ (i_z-2+j) * nc_taylor + k ]</code>, 00731 for j = 0, 1, 2 , for k = 0 , ... , p-1, 00732 is the k-th order Taylor coefficient corresponding to z_j. 00733 \n 00734 \b Output: <code>taylor [ (i_z-2+j) * nc_taylor + k ]</code>, 00735 is the k-th order Taylor coefficient corresponding to z_j. 00736 00737 \par Checked Assertions 00738 \li NumArg(op) == 2 00739 \li NumRes(op) == 3 00740 \li If x is a variable, arg[0] < i_z - 2 00741 \li If y is a variable, arg[1] < i_z - 2 00742 \li q < nc_taylor 00743 \li p <= q 00744 */ 00745 template <class Base> 00746 inline void forward_pow_op( 00747 size_t p , 00748 size_t q , 00749 size_t i_z , 00750 const addr_t* arg , 00751 const Base* parameter , 00752 size_t nc_taylor , 00753 Base* taylor ) 00754 { 00755 // This routine is only for documentaiton, it should not be used 00756 CPPAD_ASSERT_UNKNOWN( false ); 00757 } 00758 /*! 00759 Prototype for zero order forward mode z = pow(x, y) (not used). 00760 00761 \tparam Base 00762 base type for the operator; i.e., this operation was recorded 00763 using AD< \a Base > and computations by this routine are done using type 00764 \a Base. 00765 00766 \param i_z 00767 variable index corresponding to the last (primary) result for this operation; 00768 i.e. the row index in \a taylor corresponding to z. 00769 Note that there are three results for this operation, 00770 below they are referred to as z_0, z_1, z_2 and correspond to 00771 \verbatim 00772 z_0 = log(x) 00773 z_1 = z0 * y 00774 z_2 = exp(z1) 00775 \endverbatim 00776 It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). 00777 00778 \param arg 00779 \a arg[0] 00780 index corresponding to the left operand for this operator; 00781 i.e. the index corresponding to x. 00782 \n 00783 \a arg[1] 00784 index corresponding to the right operand for this operator; 00785 i.e. the index corresponding to y. 00786 00787 \param parameter 00788 If x is a parameter, \a parameter [ \a arg[0] ] 00789 is the value corresponding to x. 00790 \n 00791 If y is a parameter, \a parameter [ \a arg[1] ] 00792 is the value corresponding to y. 00793 00794 \param nc_taylor 00795 number of colums in the matrix containing all the Taylor coefficients. 00796 00797 \param taylor 00798 \b Input: If x is a variable, \a taylor [ \a arg[0] * \a nc_taylor + 0 ] 00799 is the zero order Taylor coefficient corresponding to x. 00800 \n 00801 \b Input: If y is a variable, \a taylor [ \a arg[1] * \a nc_taylor + 0 ] 00802 is the k-th order Taylor coefficient corresponding to y. 00803 \n 00804 \b Output: \a taylor [ \a (i_z - 2 + j) * \a nc_taylor + 0 ] 00805 is the zero order Taylor coefficient corresponding to z_j. 00806 00807 \par Checked Assertions 00808 \li NumArg(op) == 2 00809 \li NumRes(op) == 3 00810 \li If x is a variable, \a arg[0] < \a i_z - 2 00811 \li If y is a variable, \a arg[1] < \a i_z - 2 00812 */ 00813 template <class Base> 00814 inline void forward_pow_op_0( 00815 size_t i_z , 00816 const addr_t* arg , 00817 const Base* parameter , 00818 size_t nc_taylor , 00819 Base* taylor ) 00820 { 00821 // This routine is only for documentaiton, it should not be used 00822 CPPAD_ASSERT_UNKNOWN( false ); 00823 } 00824 /*! 00825 Prototype for reverse mode z = pow(x, y) (not used). 00826 00827 This routine is given the partial derivatives of a function 00828 G( z , y , x , w , ... ) 00829 and it uses them to compute the partial derivatives of 00830 \verbatim 00831 H( y , x , w , u , ... ) = G[ pow(x , y) , y , x , w , u , ... ] 00832 \endverbatim 00833 00834 \tparam Base 00835 base type for the operator; i.e., this operation was recorded 00836 using AD< \a Base > and computations by this routine are done using type 00837 \a Base . 00838 00839 \param d 00840 highest order Taylor coefficient that 00841 we are computing the partial derivatives with respect to. 00842 00843 \param i_z 00844 variable index corresponding to the last (primary) result for this operation; 00845 i.e. the row index in \a taylor corresponding to z. 00846 Note that there are three results for this operation, 00847 below they are referred to as z_0, z_1, z_2 and correspond to 00848 \verbatim 00849 z_0 = log(x) 00850 z_1 = z0 * y 00851 z_2 = exp(z1) 00852 \endverbatim 00853 It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). 00854 00855 \param arg 00856 \a arg[0] 00857 index corresponding to the left operand for this operator; 00858 i.e. the index corresponding to x. 00859 \n 00860 \a arg[1] 00861 index corresponding to the right operand for this operator; 00862 i.e. the index corresponding to y. 00863 00864 \param parameter 00865 If x is a parameter, \a parameter [ \a arg[0] ] 00866 is the value corresponding to x. 00867 \n 00868 If y is a parameter, \a parameter [ \a arg[1] ] 00869 is the value corresponding to y. 00870 00871 \param nc_taylor 00872 number of colums in the matrix containing all the Taylor coefficients. 00873 00874 \param taylor 00875 \a taylor [ \a (i_z - 2 + j) * \a nc_taylor + k ] 00876 for j = 0, 1, 2 and k = 0 , ... , \a d 00877 is the k-th order Taylor coefficient corresponding to z_j. 00878 \n 00879 If x is a variable, \a taylor [ \a arg[0] * \a nc_taylor + k ] 00880 for k = 0 , ... , \a d 00881 is the k-th order Taylor coefficient corresponding to x. 00882 \n 00883 If y is a variable, \a taylor [ \a arg[1] * \a nc_taylor + k ] 00884 for k = 0 , ... , \a d 00885 is the k-th order Taylor coefficient corresponding to y. 00886 00887 \param nc_partial 00888 number of colums in the matrix containing all the partial derivatives. 00889 00890 \param partial 00891 \b Input: \a partial [ \a (i_z - 2 + j) * \a nc_partial + k ] 00892 for j = 0, 1, 2, and k = 0 , ... , \a d 00893 is the partial derivative of 00894 G( z , y , x , w , u , ... ) 00895 with respect to the k-th order Taylor coefficient for z_j. 00896 \n 00897 \b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] 00898 for k = 0 , ... , \a d 00899 is the partial derivative of G( z , y , x , w , u , ... ) with respect to 00900 the k-th order Taylor coefficient for x. 00901 \n 00902 \b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] 00903 for k = 0 , ... , \a d 00904 is the partial derivative of G( z , x , w , u , ... ) with respect to 00905 the k-th order Taylor coefficient for the auxillary variable y. 00906 \n 00907 \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] 00908 for k = 0 , ... , \a d 00909 is the partial derivative of H( y , x , w , u , ... ) with respect to 00910 the k-th order Taylor coefficient for x. 00911 \n 00912 \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] 00913 for k = 0 , ... , \a d 00914 is the partial derivative of H( y , x , w , u , ... ) with respect to 00915 the k-th order Taylor coefficient for y. 00916 \n 00917 \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] 00918 for j = 0 , 1 , 2 and for k = 0 , ... , \a d 00919 may be used as work space; i.e., may change in an unspecified manner. 00920 00921 \par Checked Assumptions 00922 \li NumArg(op) == 2 00923 \li NumRes(op) == 3 00924 \li \a If x is a variable, arg[0] < \a i_z - 2 00925 \li \a If y is a variable, arg[1] < \a i_z - 2 00926 \li \a d < \a nc_taylor 00927 \li \a d < \a nc_partial 00928 */ 00929 template <class Base> 00930 inline void reverse_pow_op( 00931 size_t d , 00932 size_t i_z , 00933 addr_t* arg , 00934 const Base* parameter , 00935 size_t nc_taylor , 00936 const Base* taylor , 00937 size_t nc_partial , 00938 Base* partial ) 00939 { 00940 // This routine is only for documentaiton, it should not be used 00941 CPPAD_ASSERT_UNKNOWN( false ); 00942 } 00943 00944 // ==================== Sparsity Calculations ============================== 00945 /*! 00946 Prototype for reverse mode Hessian sparsity unary operators. 00947 00948 This routine is given the forward mode Jacobian sparsity patterns for x. 00949 It is also given the reverse mode dependence of G on z. 00950 In addition, it is given the revese mode Hessian sparsity 00951 for the quanity of interest G(z , y , ... ) 00952 and it uses them to compute the sparsity patterns for 00953 \verbatim 00954 H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] 00955 \endverbatim 00956 00957 \tparam Vector_set 00958 is the type used for vectors of sets. It can be either 00959 \c sparse_pack, \c sparse_set, or \c sparse_list. 00960 00961 \param i_z 00962 variable index corresponding to the result for this operation; 00963 i.e. the row index in sparsity corresponding to z. 00964 00965 \param i_x 00966 variable index corresponding to the argument for this operator; 00967 i.e. the row index in sparsity corresponding to x. 00968 00969 \param rev_jacobian 00970 \a rev_jacobian[i_z] 00971 is all false (true) if the Jacobian of G with respect to z must be zero 00972 (may be non-zero). 00973 \n 00974 \n 00975 \a rev_jacobian[i_x] 00976 is all false (true) if the Jacobian with respect to x must be zero 00977 (may be non-zero). 00978 On input, it corresponds to the function G, 00979 and on output it corresponds to the function H. 00980 00981 \param for_jac_sparsity 00982 The set with index \a i_x in for_jac_sparsity 00983 is the forward mode Jacobian sparsity pattern for the variable x. 00984 00985 \param rev_hes_sparsity 00986 The set with index \a i_z in in \a rev_hes_sparsity 00987 is the Hessian sparsity pattern for the fucntion G 00988 where one of the partials derivative is with respect to z. 00989 \n 00990 \n 00991 The set with index \a i_x in \a rev_hes_sparsity 00992 is the Hessian sparsity pattern 00993 where one of the partials derivative is with respect to x. 00994 On input, it corresponds to the function G, 00995 and on output it corresponds to the function H. 00996 00997 \par Checked Assertions: 00998 \li \a i_x < \a i_z 00999 */ 01000 01001 template <class Vector_set> 01002 inline void reverse_sparse_hessian_unary_op( 01003 size_t i_z , 01004 size_t i_x , 01005 bool* rev_jacobian , 01006 Vector_set& for_jac_sparsity , 01007 Vector_set& rev_hes_sparsity ) 01008 { 01009 // This routine is only for documentaiton, it should not be used 01010 CPPAD_ASSERT_UNKNOWN( false ); 01011 } 01012 01013 /*! 01014 Prototype for reverse mode Hessian sparsity binary operators. 01015 01016 This routine is given the sparsity patterns the Hessian 01017 of a function G(z, y, x, ... ) 01018 and it uses them to compute the sparsity patterns for the Hessian of 01019 \verbatim 01020 H( y, x, w , u , ... ) = G[ z(x,y) , y , x , w , u , ... ] 01021 \endverbatim 01022 01023 \tparam Vector_set 01024 is the type used for vectors of sets. It can be either 01025 \c sparse_pack, \c sparse_set, or \c sparse_list. 01026 01027 \param i_z 01028 variable index corresponding to the result for this operation; 01029 i.e. the row index in sparsity corresponding to z. 01030 01031 \param arg 01032 \a arg[0] 01033 variable index corresponding to the left operand for this operator; 01034 i.e. the set with index \a arg[0] in \a var_sparsity 01035 is the spasity pattern correspoding to x. 01036 \n 01037 \n arg[1] 01038 variable index corresponding to the right operand for this operator; 01039 i.e. the row index in sparsity patterns corresponding to y. 01040 01041 \param jac_reverse 01042 \a jac_reverse[i_z] 01043 is false (true) if the Jacobian of G with respect to z is always zero 01044 (may be non-zero). 01045 \n 01046 \n 01047 \a jac_reverse[ \a arg[0] ] 01048 is false (true) if the Jacobian with respect to x is always zero 01049 (may be non-zero). 01050 On input, it corresponds to the function G, 01051 and on output it corresponds to the function H. 01052 \n 01053 \n 01054 \a jac_reverse[ \a arg[1] ] 01055 is false (true) if the Jacobian with respect to y is always zero 01056 (may be non-zero). 01057 On input, it corresponds to the function G, 01058 and on output it corresponds to the function H. 01059 01060 \param for_jac_sparsity 01061 The set with index \a arg[0] in \a for_jac_sparsity for the 01062 is the forward Jacobian sparsity pattern for x. 01063 \n 01064 \n 01065 The set with index \a arg[1] in \a for_jac_sparsity 01066 is the forward sparsity pattern for y. 01067 01068 \param rev_hes_sparsity 01069 The set wiht index \a i_x in \a rev_hes_sparsity 01070 is the Hessian sparsity pattern for the function G 01071 where one of the partial derivatives is with respect to z. 01072 \n 01073 \n 01074 The set with index \a arg[0] in \a rev_hes_sparsity 01075 is the Hessian sparsity pattern where one of the 01076 partial derivatives is with respect to x. 01077 On input, it corresponds to the function G, 01078 and on output it correspondst to H. 01079 \n 01080 \n 01081 The set with index \a arg[1] in \a rev_hes_sparsity 01082 is the Hessian sparsity pattern where one of the 01083 partial derivatives is with respect to y. 01084 On input, it corresponds to the function G, 01085 and on output it correspondst to H. 01086 01087 \par Checked Assertions: 01088 \li \a arg[0] < \a i_z 01089 \li \a arg[1] < \a i_z 01090 */ 01091 template <class Vector_set> 01092 inline void reverse_sparse_hessian_binary_op( 01093 size_t i_z , 01094 const addr_t* arg , 01095 bool* jac_reverse , 01096 Vector_set& for_jac_sparsity , 01097 Vector_set& rev_hes_sparsity ) 01098 { 01099 // This routine is only for documentaiton, it should not be used 01100 CPPAD_ASSERT_UNKNOWN( false ); 01101 } 01102 01103 01104 } // END_CPPAD_NAMESPACE 01105 # endif