/usr/include/cppad/local/forward0sweep.hpp is in cppad 2017.00.00.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 | // $Id: forward0sweep.hpp 3853 2016-12-14 14:40:11Z bradbell $
# ifndef CPPAD_LOCAL_FORWARD0SWEEP_HPP
# define CPPAD_LOCAL_FORWARD0SWEEP_HPP
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
CppAD is distributed under multiple licenses. This distribution is under
the terms of the
GNU General Public License Version 3.
A copy of this license is included in the COPYING file of this distribution.
Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
-------------------------------------------------------------------------- */
namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE
/*!
\file forward0sweep.hpp
Compute zero order forward mode Taylor coefficients.
*/
/*
\def CPPAD_ATOMIC_CALL
This avoids warnings when NDEBUG is defined and user_ok is not used.
If NDEBUG is defined, this resolves to
\code
user_atom->forward
\endcode
otherwise, it respolves to
\code
user_ok = user_atom->forward
\endcode
This maco is undefined at the end of this file to facillitate is
use with a different definition in other files.
*/
# ifdef NDEBUG
# define CPPAD_ATOMIC_CALL user_atom->forward
# else
# define CPPAD_ATOMIC_CALL user_ok = user_atom->forward
# endif
/*!
\def CPPAD_FORWARD0SWEEP_TRACE
This value is either zero or one.
Zero is the normal operational value.
If it is one, a trace of every forward0sweep computation is printed.
(Note that forward0sweep is not used if CPPAD_USE_FORWARD0SWEEP is zero).
*/
# define CPPAD_FORWARD0SWEEP_TRACE 0
/*!
Compute zero order forward mode Taylor coefficients.
<!-- define forward0sweep_doc_define -->
\tparam Base
The type used during the forward mode computations; i.e., the corresponding
recording of operations used the type AD<Base>.
\param s_out
Is the stream where output corresponding to PriOp operations will
be written.
\param print
If print is false,
suppress the output that is otherwise generated by the c PriOp instructions.
\param n
is the number of independent variables on the tape.
\param numvar
is the total number of variables on the tape.
This is also equal to the number of rows in the matrix taylor; i.e.,
play->num_var_rec().
\param play
The information stored in play
is a recording of the operations corresponding to the function
\f[
F : {\bf R}^n \rightarrow {\bf R}^m
\f]
where \f$ n \f$ is the number of independent variables and
\f$ m \f$ is the number of dependent variables.
\n
\n
The object play is effectly constant.
The exception to this is that while palying back the tape
the object play holds information about the current location
with in the tape and this changes during palyback.
\param J
Is the number of columns in the coefficient matrix taylor.
This must be greater than or equal one.
<!-- end forward0sweep_doc_define -->
\param taylor
\n
\b Input:
For i = 1 , ... , n,
<code>taylor [i * J + 0]</code>
variable with index j on the tape
(these are the independent variables).
\n
\n
\b Output:
For i = n + 1, ... , numvar - 1,
<code>taylor [i * J + 0]</code>
is the zero order Taylor coefficient for the variable with
index i on the tape.
\param cskip_op
Is a vector with size play->num_op_rec().
The input value of the elements does not matter.
Upon return, if cskip_op[i] is true, the operator index i
does not affect any of the dependent variable
(given the value of the independent variables).
\param var_by_load_op
Is a vector with size play->num_load_op_rec().
The input value of the elements does not matter.
Upon return,
it is the variable index corresponding the result for each load operator.
In the case where the index is zero,
the load operator results in a parameter (not a variable).
Note that the is no variable with index zero on the tape.
\param compare_change_count
Is the count value for changing number and op_index during
zero order foward mode.
\param compare_change_number
If compare_change_count is zero, this value is set to zero.
Otherwise, the return value is the number of comparision operations
that have a different result from when the information in
play was recorded.
\param compare_change_op_index
If compare_change_count is zero, this value is set to zero.
Otherwise it is the operator index (see forward_next) for the count-th
comparision operation that has a different result from when the information in
play was recorded.
*/
template <class Base>
void forward0sweep(
std::ostream& s_out,
bool print,
size_t n,
size_t numvar,
local::player<Base>* play,
size_t J,
Base* taylor,
bool* cskip_op,
pod_vector<addr_t>& var_by_load_op,
size_t compare_change_count,
size_t& compare_change_number,
size_t& compare_change_op_index
)
{ CPPAD_ASSERT_UNKNOWN( J >= 1 );
CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar );
// use p, q, r so other forward sweeps can use code defined here
size_t p = 0;
size_t q = 0;
size_t r = 1;
/*
<!-- define forward0sweep_code_define -->
*/
// op code for current instruction
OpCode op;
// index for current instruction
size_t i_op;
// next variables
size_t i_var;
// operation argument indices
const addr_t* arg = CPPAD_NULL;
// initialize the comparision operator counter
if( p == 0 )
{ compare_change_number = 0;
compare_change_op_index = 0;
}
// If this includes a zero calculation, initialize this information
pod_vector<bool> isvar_by_ind;
pod_vector<size_t> index_by_ind;
if( p == 0 )
{ size_t i;
// this includes order zero calculation, initialize vector indices
size_t num = play->num_vec_ind_rec();
if( num > 0 )
{ isvar_by_ind.extend(num);
index_by_ind.extend(num);
for(i = 0; i < num; i++)
{ index_by_ind[i] = play->GetVecInd(i);
isvar_by_ind[i] = false;
}
}
// includes zero order, so initialize conditional skip flags
num = play->num_op_rec();
for(i = 0; i < num; i++)
cskip_op[i] = false;
}
// work space used by UserOp.
vector<bool> user_vx; // empty vecotor
vector<bool> user_vy; // empty vecotor
vector<Base> user_tx; // argument vector Taylor coefficients
vector<Base> user_ty; // result vector Taylor coefficients
//
atomic_base<Base>* user_atom = CPPAD_NULL; // user's atomic op calculator
# ifndef NDEBUG
bool user_ok = false; // atomic op return value
# endif
//
// information defined by forward_user
size_t user_old=0, user_m=0, user_n=0, user_i=0, user_j=0;
enum_user_state user_state = start_user; // proper initialization
// length of the parameter vector (used by CppAD assert macros)
const size_t num_par = play->num_par_rec();
// pointer to the beginning of the parameter vector
const Base* parameter = CPPAD_NULL;
if( num_par > 0 )
parameter = play->GetPar();
// length of the text vector (used by CppAD assert macros)
const size_t num_text = play->num_text_rec();
// pointer to the beginning of the text vector
const char* text = CPPAD_NULL;
if( num_text > 0 )
text = play->GetTxt(0);
/*
<!-- end forward0sweep_code_define -->
*/
# if CPPAD_FORWARD0SWEEP_TRACE
// flag as to when to trace user function values
bool user_trace = false;
// variable indices for results vector
// (done differently for order zero).
vector<size_t> user_iy;
# endif
// skip the BeginOp at the beginning of the recording
play->forward_start(op, arg, i_op, i_var);
CPPAD_ASSERT_UNKNOWN( op == BeginOp );
# if CPPAD_FORWARD0SWEEP_TRACE
std::cout << std::endl;
# endif
bool flag; // a temporary flag to use in switch cases
bool more_operators = true;
while(more_operators)
{
// this op
play->forward_next(op, arg, i_op, i_var);
CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) );
CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) );
CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() );
CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, i_var);
// check if we are skipping this operation
while( cskip_op[i_op] )
{ switch(op)
{ case CSumOp:
// CSumOp has a variable number of arguments
play->forward_csum(op, arg, i_op, i_var);
break;
case CSkipOp:
// CSkip has a variable number of arguments
play->forward_cskip(op, arg, i_op, i_var);
break;
case UserOp:
{ // skip all operations in this user atomic call
CPPAD_ASSERT_UNKNOWN( user_state == start_user );
play->forward_user(op, user_state,
user_old, user_m, user_n, user_i, user_j
);
size_t n_skip = user_m + user_n + 1;
for(size_t i = 0; i < n_skip; i++)
{ play->forward_next(op, arg, i_op, i_var);
play->forward_user(op, user_state,
user_old, user_m, user_n, user_i, user_j
);
}
CPPAD_ASSERT_UNKNOWN( user_state == start_user );
}
break;
default:
break;
}
play->forward_next(op, arg, i_op, i_var);
CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() );
}
// action to take depends on the case
switch( op )
{
case AbsOp:
forward_abs_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case AddvvOp:
forward_addvv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case AddpvOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par );
forward_addpv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case AcosOp:
// sqrt(1 - x * x), acos(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_acos_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
# if CPPAD_USE_CPLUSPLUS_2011
case AcoshOp:
// sqrt(x * x - 1), acosh(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_acosh_op_0(i_var, arg[0], J, taylor);
break;
# endif
// -------------------------------------------------
case AsinOp:
// sqrt(1 - x * x), asin(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_asin_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
# if CPPAD_USE_CPLUSPLUS_2011
case AsinhOp:
// sqrt(1 + x * x), asinh(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_asinh_op_0(i_var, arg[0], J, taylor);
break;
# endif
// -------------------------------------------------
case AtanOp:
// 1 + x * x, atan(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_atan_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
# if CPPAD_USE_CPLUSPLUS_2011
case AtanhOp:
// 1 - x * x, atanh(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_atanh_op_0(i_var, arg[0], J, taylor);
break;
# endif
// -------------------------------------------------
case CExpOp:
// Use the general case with d == 0
// (could create an optimzied verison for this case)
forward_cond_op_0(
i_var, arg, num_par, parameter, J, taylor
);
break;
// ---------------------------------------------------
case CosOp:
// sin(x), cos(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_cos_op_0(i_var, arg[0], J, taylor);
break;
// ---------------------------------------------------
case CoshOp:
// sinh(x), cosh(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_cosh_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case CSkipOp:
// CSkipOp has a variable number of arguments and
// forward_next thinks it has no arguments.
// we must inform forward_next of this special case.
forward_cskip_op_0(
i_var, arg, num_par, parameter, J, taylor, cskip_op
);
play->forward_cskip(op, arg, i_op, i_var);
break;
// -------------------------------------------------
case CSumOp:
// CSumOp has a variable number of arguments and
// forward_next thinks it has no arguments.
// we must inform forward_next of this special case.
forward_csum_op(
0, 0, i_var, arg, num_par, parameter, J, taylor
);
play->forward_csum(op, arg, i_op, i_var);
break;
// -------------------------------------------------
case DisOp:
forward_dis_op(p, q, r, i_var, arg, J, taylor);
break;
// -------------------------------------------------
case DivvvOp:
forward_divvv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case DivpvOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par );
forward_divpv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case DivvpOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par );
forward_divvp_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case EndOp:
CPPAD_ASSERT_NARG_NRES(op, 0, 0);
more_operators = false;
break;
// -------------------------------------------------
case EqpvOp:
if( compare_change_count )
{ forward_eqpv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case EqvvOp:
if( compare_change_count )
{ forward_eqvv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
# if CPPAD_USE_CPLUSPLUS_2011
case ErfOp:
forward_erf_op_0(i_var, arg, parameter, J, taylor);
break;
# endif
// -------------------------------------------------
case ExpOp:
forward_exp_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
# if CPPAD_USE_CPLUSPLUS_2011
case Expm1Op:
forward_expm1_op_0(i_var, arg[0], J, taylor);
break;
# endif
// -------------------------------------------------
case InvOp:
CPPAD_ASSERT_NARG_NRES(op, 0, 1);
break;
// ---------------------------------------------------
case LdpOp:
forward_load_p_op_0(
play,
i_var,
arg,
parameter,
J,
taylor,
isvar_by_ind.data(),
index_by_ind.data(),
var_by_load_op.data()
);
break;
// -------------------------------------------------
case LdvOp:
forward_load_v_op_0(
play,
i_var,
arg,
parameter,
J,
taylor,
isvar_by_ind.data(),
index_by_ind.data(),
var_by_load_op.data()
);
break;
// -------------------------------------------------
case LepvOp:
if( compare_change_count )
{ forward_lepv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case LevpOp:
if( compare_change_count )
{ forward_levp_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case LevvOp:
if( compare_change_count )
{ forward_levv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case LogOp:
forward_log_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
# if CPPAD_USE_CPLUSPLUS_2011
case Log1pOp:
forward_log1p_op_0(i_var, arg[0], J, taylor);
break;
# endif
// -------------------------------------------------
case LtpvOp:
if( compare_change_count )
{ forward_ltpv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case LtvpOp:
if( compare_change_count )
{ forward_ltvp_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case LtvvOp:
if( compare_change_count )
{ forward_ltvv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case MulpvOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par );
forward_mulpv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case MulvvOp:
forward_mulvv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case NepvOp:
if( compare_change_count )
{ forward_nepv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case NevvOp:
if( compare_change_count )
{ forward_nevv_op_0(
compare_change_number, arg, parameter, J, taylor
);
{ if( compare_change_count == compare_change_number )
compare_change_op_index = i_op;
}
}
break;
// -------------------------------------------------
case ParOp:
forward_par_op_0(
i_var, arg, num_par, parameter, J, taylor
);
break;
// -------------------------------------------------
case PowvpOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par );
forward_powvp_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case PowpvOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par );
forward_powpv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case PowvvOp:
forward_powvv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case PriOp:
if( print ) forward_pri_0(s_out,
arg, num_text, text, num_par, parameter, J, taylor
);
break;
// -------------------------------------------------
case SignOp:
// cos(x), sin(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_sign_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case SinOp:
// cos(x), sin(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_sin_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case SinhOp:
// cosh(x), sinh(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_sinh_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case SqrtOp:
forward_sqrt_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case StppOp:
forward_store_pp_op_0(
i_var,
arg,
num_par,
J,
taylor,
isvar_by_ind.data(),
index_by_ind.data()
);
break;
// -------------------------------------------------
case StpvOp:
forward_store_pv_op_0(
i_var,
arg,
num_par,
J,
taylor,
isvar_by_ind.data(),
index_by_ind.data()
);
break;
// -------------------------------------------------
case StvpOp:
forward_store_vp_op_0(
i_var,
arg,
num_par,
J,
taylor,
isvar_by_ind.data(),
index_by_ind.data()
);
break;
// -------------------------------------------------
case StvvOp:
forward_store_vv_op_0(
i_var,
arg,
num_par,
J,
taylor,
isvar_by_ind.data(),
index_by_ind.data()
);
break;
// -------------------------------------------------
case SubvvOp:
forward_subvv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case SubpvOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par );
forward_subpv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case SubvpOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par );
forward_subvp_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case TanOp:
// tan(x)^2, tan(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_tan_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case TanhOp:
// tanh(x)^2, tanh(x)
CPPAD_ASSERT_UNKNOWN( i_var < numvar );
forward_tanh_op_0(i_var, arg[0], J, taylor);
break;
// -------------------------------------------------
case UserOp:
// start or end an atomic operation sequence
flag = user_state == start_user;
user_atom = play->forward_user(op, user_state,
user_old, user_m, user_n, user_i, user_j
);
if( flag )
{ user_tx.resize(user_n);
user_ty.resize(user_m);
# if CPPAD_FORWARD0SWEEP_TRACE
user_iy.resize(user_m);
# endif
}
else
{
# ifndef NDEBUG
if( ! user_ok )
{ std::string msg =
user_atom->afun_name()
+ ": atomic_base.forward: returned false";
CPPAD_ASSERT_KNOWN(false, msg.c_str() );
}
# endif
# if CPPAD_FORWARD0SWEEP_TRACE
user_trace = true;
# endif
}
break;
case UsrapOp:
// parameter argument in an atomic operation sequence
CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par );
user_tx[user_j] = parameter[ arg[0] ];
play->forward_user(op, user_state,
user_old, user_m, user_n, user_i, user_j
);
if( user_j == user_n )
{ // call users function for this operation
user_atom->set_old(user_old);
CPPAD_ATOMIC_CALL(p, q,
user_vx, user_vy, user_tx, user_ty
);
}
break;
case UsravOp:
// variable argument in an atomic operation sequence
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var );
user_tx[user_j] = taylor[ arg[0] * J + 0 ];
play->forward_user(op, user_state,
user_old, user_m, user_n, user_i, user_j
);
if( user_j == user_n )
{ // call users function for this operation
user_atom->set_old(user_old);
CPPAD_ATOMIC_CALL(p, q,
user_vx, user_vy, user_tx, user_ty
);
}
break;
case UsrrpOp:
// parameter result in an atomic operation sequence
# if CPPAD_FORWARD0SWEEP_TRACE
user_iy[user_i] = 0;
# endif
play->forward_user(op, user_state,
user_old, user_m, user_n, user_i, user_j
);
break;
case UsrrvOp:
// variable result in an atomic operation sequence
# if CPPAD_FORWARD0SWEEP_TRACE
user_iy[user_i] = i_var;
# endif
taylor[ i_var * J + 0 ] = user_ty[user_i];
play->forward_user(op, user_state,
user_old, user_m, user_n, user_i, user_j
);
break;
// -------------------------------------------------
case ZmulpvOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par );
forward_zmulpv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case ZmulvpOp:
CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par );
forward_zmulvp_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
case ZmulvvOp:
forward_zmulvv_op_0(i_var, arg, parameter, J, taylor);
break;
// -------------------------------------------------
default:
CPPAD_ASSERT_UNKNOWN(false);
}
# if CPPAD_FORWARD0SWEEP_TRACE
size_t d = 0;
if( user_trace )
{ user_trace = false;
CPPAD_ASSERT_UNKNOWN( op == UserOp );
CPPAD_ASSERT_UNKNOWN( NumArg(UsrrvOp) == 0 );
for(size_t i = 0; i < user_m; i++) if( user_iy[i] > 0 )
{ size_t i_tmp = (i_op + i) - user_m;
printOp(
std::cout,
play,
i_tmp,
user_iy[i],
UsrrvOp,
CPPAD_NULL
);
Base* Z_tmp = taylor + user_iy[i] * J;
printOpResult(
std::cout,
d + 1,
Z_tmp,
0,
(Base *) CPPAD_NULL
);
std::cout << std::endl;
}
}
Base* Z_tmp = taylor + i_var * J;
const addr_t* arg_tmp = arg;
if( op == CSumOp )
arg_tmp = arg - arg[-1] - 4;
if( op == CSkipOp )
arg_tmp = arg - arg[-1] - 7;
if( op != UsrrvOp )
{
printOp(
std::cout,
play,
i_op,
i_var,
op,
arg_tmp
);
if( NumRes(op) > 0 ) printOpResult(
std::cout,
d + 1,
Z_tmp,
0,
(Base *) CPPAD_NULL
);
std::cout << std::endl;
}
}
std::cout << std::endl;
# else
}
# endif
CPPAD_ASSERT_UNKNOWN( user_state == start_user );
CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() );
return;
}
} } // END_CPPAD_LOCAL_NAMESPACE
// preprocessor symbols that are local to this file
# undef CPPAD_FORWARD0SWEEP_TRACE
# undef CPPAD_ATOMIC_CALL
# endif
|