CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
for_jac_sweep.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_LOCAL_FOR_JAC_SWEEP_HPP
2 # define CPPAD_LOCAL_FOR_JAC_SWEEP_HPP
3 /* --------------------------------------------------------------------------
4 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
5 
6 CppAD is distributed under multiple licenses. This distribution is under
7 the terms of the
8  Eclipse Public License Version 1.0.
9 
10 A copy of this license is included in the COPYING file of this distribution.
11 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
12 -------------------------------------------------------------------------- */
13 
14 # include <set>
16 
17 namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE
18 /*!
19 \file for_jac_sweep.hpp
20 Compute Forward mode Jacobian sparsity patterns.
21 */
22 
23 /*!
24 \def CPPAD_FOR_JAC_SWEEP_TRACE
25 This value is either zero or one.
26 Zero is the normal operational value.
27 If it is one, a trace of every for_jac_sweep computation is printed.
28 */
29 # define CPPAD_FOR_JAC_SWEEP_TRACE 0
30 
31 /*!
32 Given the sparsity pattern for the independent variables,
33 ForJacSweep computes the sparsity pattern for all the other variables.
34 
35 \tparam Base
36 this operation sequence was recorded using AD<Base>.
37 
38 \tparam Vector_set
39 is the type used for vectors of sets. It can be either
40 sparse_pack or sparse_list.
41 
42 \param dependency
43 Are the derivatives with respect to left and right of the expression below
44 considered to be non-zero:
45 \code
46  CondExpRel(left, right, if_true, if_false)
47 \endcode
48 This is used by the optimizer to obtain the correct dependency relations.
49 
50 \param n
51 is the number of independent variables on the tape.
52 
53 \param numvar
54 is the total number of variables on the tape; i.e.,
55 \a play->num_var_rec().
56 
57 \param play
58 The information stored in \a play
59 is a recording of the operations corresponding to a function
60 \f[
61  F : {\bf R}^n \rightarrow {\bf R}^m
62 \f]
63 where \f$ n \f$ is the number of independent variables
64 and \f$ m \f$ is the number of dependent variables.
65 
66 \param var_sparsity
67 \b Input: For j = 1 , ... , \a n,
68 the sparsity pattern for the independent variable with index (j-1)
69 corresponds to the set with index j in \a var_sparsity.
70 \n
71 \n
72 \b Output: For i = \a n + 1 , ... , \a numvar - 1,
73 the sparsity pattern for the variable with index i on the tape
74 corresponds to the set with index i in \a var_sparsity.
75 
76 \par Checked Assertions:
77 \li numvar == var_sparsity.n_set()
78 \li numvar == play->num_var_rec()
79 */
80 
81 template <class Base, class Vector_set>
83  const local::player<Base>* play,
84  bool dependency ,
85  size_t n ,
86  size_t numvar ,
87  Vector_set& var_sparsity )
88 {
89  OpCode op;
90  size_t i_op;
91  size_t i_var;
92 
93  const addr_t* arg = CPPAD_NULL;
94 
95  size_t i, j, k;
96 
97  // check numvar argument
98  CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar );
99  CPPAD_ASSERT_UNKNOWN( var_sparsity.n_set() == numvar );
100 
101  // length of the parameter vector (used by CppAD assert macros)
102  const size_t num_par = play->num_par_rec();
103 
104  // cum_sparsity accumulates sparsity pattern a cummulative sum
105  size_t limit = var_sparsity.end();
106 
107  // vecad_sparsity contains a sparsity pattern from each VecAD object
108  // to all the other variables.
109  // vecad_ind maps a VecAD index (the beginning of the
110  // VecAD object) to its from index in vecad_sparsity
111  size_t num_vecad_ind = play->num_vec_ind_rec();
112  size_t num_vecad_vec = play->num_vecad_vec_rec();
113  Vector_set vecad_sparsity;
114  pod_vector<size_t> vecad_ind;
115  if( num_vecad_vec > 0 )
116  { size_t length;
117  vecad_sparsity.resize(num_vecad_vec, limit);
118  vecad_ind.extend(num_vecad_ind);
119  j = 0;
120  for(i = 0; i < num_vecad_vec; i++)
121  { // length of this VecAD
122  length = play->GetVecInd(j);
123  // set to proper index for this VecAD
124  vecad_ind[j] = i;
125  for(k = 1; k <= length; k++)
126  vecad_ind[j+k] = num_vecad_vec; // invalid index
127  // start of next VecAD
128  j += length + 1;
129  }
130  CPPAD_ASSERT_UNKNOWN( j == play->num_vec_ind_rec() );
131  }
132 
133  // --------------------------------------------------------------
134  // user's atomic op calculator
135  atomic_base<Base>* user_atom = CPPAD_NULL;
136  //
137  // work space used by UserOp.
138  vector<Base> user_x; // value of parameter arguments to function
139  vector<size_t> user_ix; // variable index (on tape) for each argument
140  vector<size_t> user_iy; // variable index (on tape) for each result
141  //
142  // information set by forward_user (initialization to avoid warnings)
143  size_t user_old=0, user_m=0, user_n=0, user_i=0, user_j=0;
144  // information set by forward_user (necessary initialization)
145  enum_user_state user_state = start_user;
146  // --------------------------------------------------------------
147  //
148  // pointer to the beginning of the parameter vector
149  // (used by user atomic functions)
150  const Base* parameter = CPPAD_NULL;
151  if( num_par > 0 )
152  parameter = play->GetPar();
153 
154 # if CPPAD_FOR_JAC_SWEEP_TRACE
155  vector<size_t> user_usrrp; // parameter index for UsrrpOp operators
156  std::cout << std::endl;
157  CppAD::vectorBool z_value(limit);
158 # endif
159 
160  // skip the BeginOp at the beginning of the recording
161  i_op = 0;
162  play->get_op_info(i_op, op, arg, i_var);
163  CPPAD_ASSERT_UNKNOWN( op == BeginOp );
164  bool more_operators = true;
165  while(more_operators)
166  { bool flag; // temporary for use in switch cases.
167 
168  // this op
169  play->get_op_info(++i_op, op, arg, i_var);
170 
171  // rest of information depends on the case
172  switch( op )
173  {
174  case AbsOp:
175  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
177  i_var, arg[0], var_sparsity
178  );
179  break;
180  // -------------------------------------------------
181 
182  case AddvvOp:
183  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
185  i_var, arg, var_sparsity
186  );
187  break;
188  // -------------------------------------------------
189 
190  case AddpvOp:
191  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
193  i_var, arg[1], var_sparsity
194  );
195  break;
196  // -------------------------------------------------
197 
198  case AcosOp:
199  // sqrt(1 - x * x), acos(x)
200  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
202  i_var, arg[0], var_sparsity
203  );
204  break;
205  // -------------------------------------------------
206 
207 # if CPPAD_USE_CPLUSPLUS_2011
208  case AcoshOp:
209  // sqrt(x * x - 1), acosh(x)
210  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
212  i_var, arg[0], var_sparsity
213  );
214  break;
215 # endif
216  // -------------------------------------------------
217 
218  case AsinOp:
219  // sqrt(1 - x * x), asin(x)
220  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
222  i_var, arg[0], var_sparsity
223  );
224  break;
225  // -------------------------------------------------
226 
227 # if CPPAD_USE_CPLUSPLUS_2011
228  case AsinhOp:
229  // sqrt(1 + x * x), asinh(x)
230  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
232  i_var, arg[0], var_sparsity
233  );
234  break;
235 # endif
236  // -------------------------------------------------
237 
238  case AtanOp:
239  // 1 + x * x, atan(x)
240  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
242  i_var, arg[0], var_sparsity
243  );
244  break;
245  // -------------------------------------------------
246 
247 # if CPPAD_USE_CPLUSPLUS_2011
248  case AtanhOp:
249  // 1 - x * x, atanh(x)
250  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
252  i_var, arg[0], var_sparsity
253  );
254  break;
255 # endif
256  // -------------------------------------------------
257 
258  case CSkipOp:
259  break;
260  // -------------------------------------------------
261 
262  case CSumOp:
264  i_var, arg, var_sparsity
265  );
266  break;
267  // -------------------------------------------------
268 
269  case CExpOp:
271  dependency, i_var, arg, num_par, var_sparsity
272  );
273  break;
274  // --------------------------------------------------
275 
276  case CosOp:
277  // sin(x), cos(x)
278  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
280  i_var, arg[0], var_sparsity
281  );
282  break;
283  // ---------------------------------------------------
284 
285  case CoshOp:
286  // sinh(x), cosh(x)
287  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
289  i_var, arg[0], var_sparsity
290  );
291  break;
292  // -------------------------------------------------
293 
294  case DisOp:
295  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
296  // derivative is identically zero but dependency is not
297  if( dependency ) forward_sparse_jacobian_unary_op(
298  i_var, arg[1], var_sparsity
299  );
300  else
301  var_sparsity.clear(i_var);
302  break;
303  // -------------------------------------------------
304 
305  case DivvvOp:
306  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
308  i_var, arg, var_sparsity
309  );
310  break;
311  // -------------------------------------------------
312 
313  case DivpvOp:
314  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
316  i_var, arg[1], var_sparsity
317  );
318  break;
319  // -------------------------------------------------
320 
321  case DivvpOp:
322  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
324  i_var, arg[0], var_sparsity
325  );
326  break;
327  // -------------------------------------------------
328 
329  case EndOp:
330  CPPAD_ASSERT_NARG_NRES(op, 0, 0);
331  more_operators = false;
332  break;
333  // -------------------------------------------------
334 
335  case ErfOp:
336  // arg[1] is always the parameter 0
337  // arg[0] is always the parameter 2 / sqrt(pi)
338  CPPAD_ASSERT_NARG_NRES(op, 3, 5);
340  i_var, arg[0], var_sparsity
341  );
342  break;
343  // -------------------------------------------------
344 
345  case ExpOp:
346  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
348  i_var, arg[0], var_sparsity
349  );
350  break;
351  // -------------------------------------------------
352 
353 # if CPPAD_USE_CPLUSPLUS_2011
354  case Expm1Op:
355  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
357  i_var, arg[0], var_sparsity
358  );
359  break;
360 # endif
361  // -------------------------------------------------
362 
363  case InvOp:
364  CPPAD_ASSERT_NARG_NRES(op, 0, 1);
365  // sparsity pattern is already defined
366  break;
367  // -------------------------------------------------
368 
369  case LdpOp:
371  dependency,
372  op,
373  i_var,
374  arg,
375  num_vecad_ind,
376  vecad_ind.data(),
377  var_sparsity,
378  vecad_sparsity
379  );
380  break;
381  // -------------------------------------------------
382 
383  case LdvOp:
385  dependency,
386  op,
387  i_var,
388  arg,
389  num_vecad_ind,
390  vecad_ind.data(),
391  var_sparsity,
392  vecad_sparsity
393  );
394  break;
395  // -------------------------------------------------
396 
397  case EqpvOp:
398  case EqvvOp:
399  case LtpvOp:
400  case LtvpOp:
401  case LtvvOp:
402  case LepvOp:
403  case LevpOp:
404  case LevvOp:
405  case NepvOp:
406  case NevvOp:
407  CPPAD_ASSERT_NARG_NRES(op, 2, 0);
408  break;
409  // -------------------------------------------------
410 
411  case LogOp:
412  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
414  i_var, arg[0], var_sparsity
415  );
416  break;
417  // -------------------------------------------------
418 
419 # if CPPAD_USE_CPLUSPLUS_2011
420  case Log1pOp:
421  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
423  i_var, arg[0], var_sparsity
424  );
425  break;
426 # endif
427  // -------------------------------------------------
428 
429  case MulpvOp:
430  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
432  i_var, arg[1], var_sparsity
433  );
434  break;
435  // -------------------------------------------------
436 
437  case MulvvOp:
438  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
440  i_var, arg, var_sparsity
441  );
442  break;
443  // -------------------------------------------------
444 
445  case ParOp:
446  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
447  var_sparsity.clear(i_var);
448  break;
449  // -------------------------------------------------
450 
451  case PowvpOp:
452  CPPAD_ASSERT_NARG_NRES(op, 2, 3);
454  i_var, arg[0], var_sparsity
455  );
456  break;
457  // -------------------------------------------------
458 
459  case PowpvOp:
460  CPPAD_ASSERT_NARG_NRES(op, 2, 3);
462  i_var, arg[1], var_sparsity
463  );
464  break;
465  // -------------------------------------------------
466 
467  case PowvvOp:
468  CPPAD_ASSERT_NARG_NRES(op, 2, 3);
470  i_var, arg, var_sparsity
471  );
472  break;
473  // -------------------------------------------------
474 
475  case PriOp:
476  CPPAD_ASSERT_NARG_NRES(op, 5, 0);
477  break;
478  // -------------------------------------------------
479 
480  case SignOp:
481  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
482  // derivative is identically zero but dependency is not
483  if( dependency ) forward_sparse_jacobian_unary_op(
484  i_var, arg[0], var_sparsity
485  );
486  else
487  var_sparsity.clear(i_var);
488  break;
489  // -------------------------------------------------
490 
491  case SinOp:
492  // cos(x), sin(x)
493  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
495  i_var, arg[0], var_sparsity
496  );
497  break;
498  // -------------------------------------------------
499 
500  case SinhOp:
501  // cosh(x), sinh(x)
502  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
504  i_var, arg[0], var_sparsity
505  );
506  break;
507  // -------------------------------------------------
508 
509  case SqrtOp:
510  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
512  i_var, arg[0], var_sparsity
513  );
514  break;
515  // -------------------------------------------------
516 
517  case StppOp:
518  CPPAD_ASSERT_NARG_NRES(op, 3, 0);
519  // if both arguments are parameters does not affect sparsity
520  // or dependency
521  break;
522  // -------------------------------------------------
523 
524  case StpvOp:
526  dependency,
527  op,
528  arg,
529  num_vecad_ind,
530  vecad_ind.data(),
531  var_sparsity,
532  vecad_sparsity
533  );
534  break;
535  // -------------------------------------------------
536 
537  case StvpOp:
538  CPPAD_ASSERT_NARG_NRES(op, 3, 0);
540  dependency,
541  op,
542  arg,
543  num_vecad_ind,
544  vecad_ind.data(),
545  var_sparsity,
546  vecad_sparsity
547  );
548  break;
549  // -------------------------------------------------
550 
551  case StvvOp:
553  dependency,
554  op,
555  arg,
556  num_vecad_ind,
557  vecad_ind.data(),
558  var_sparsity,
559  vecad_sparsity
560  );
561  break;
562  // -------------------------------------------------
563 
564  case SubvvOp:
565  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
567  i_var, arg, var_sparsity
568  );
569  break;
570  // -------------------------------------------------
571 
572  case SubpvOp:
573  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
575  i_var, arg[1], var_sparsity
576  );
577  break;
578  // -------------------------------------------------
579 
580  case SubvpOp:
581  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
583  i_var, arg[0], var_sparsity
584  );
585  break;
586  // -------------------------------------------------
587 
588  case TanOp:
589  // tan(x)^2, tan(x)
590  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
592  i_var, arg[0], var_sparsity
593  );
594  break;
595  // -------------------------------------------------
596 
597  case TanhOp:
598  // tanh(x)^2, tanh(x)
599  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
601  i_var, arg[0], var_sparsity
602  );
603  break;
604  // -------------------------------------------------
605 
606  case UserOp:
607  // start or end an atomic function call
609  user_state == start_user || user_state == end_user
610  );
611  flag = user_state == start_user;
612  user_atom = play->get_user_info(op, arg, user_old, user_m, user_n);
613  if( flag )
614  { user_state = arg_user;
615  user_i = 0;
616  user_j = 0;
617  //
618  user_x.resize( user_n );
619  user_ix.resize( user_n );
620  user_iy.resize( user_m );
621 # if CPPAD_FOR_JAC_SWEEP_TRACE
622  user_usrrp.resize( user_m );
623 # endif
624  }
625  else
626  { user_state = start_user;
627  //
628  user_atom->set_old(user_old);
629  user_atom->for_sparse_jac(
630  user_x, user_ix, user_iy, var_sparsity
631  );
632  }
633  break;
634 
635  case UsrapOp:
636  // parameter argument for a user atomic function
637  CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 );
638  CPPAD_ASSERT_UNKNOWN( user_state == arg_user );
639  CPPAD_ASSERT_UNKNOWN( user_i == 0 );
640  CPPAD_ASSERT_UNKNOWN( user_j < user_n );
641  CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par );
642  //
643  user_x[user_j] = parameter[arg[0]];
644  user_ix[user_j] = 0; // special variable used for parameters
645  //
646  ++user_j;
647  if( user_j == user_n )
648  user_state = ret_user;
649  break;
650 
651  case UsravOp:
652  // variable argument for a user atomic function
653  CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 );
654  CPPAD_ASSERT_UNKNOWN( user_state == arg_user );
655  CPPAD_ASSERT_UNKNOWN( user_i == 0 );
656  CPPAD_ASSERT_UNKNOWN( user_j < user_n );
657  //
658  // argument variables not avaiable during sparsity calculations
659  user_x[user_j] = CppAD::numeric_limits<Base>::quiet_NaN();
660  user_ix[user_j] = arg[0]; // variable for this argument
661  //
662  ++user_j;
663  if( user_j == user_n )
664  user_state = ret_user;
665  break;
666 
667  case UsrrpOp:
668  // parameter result for a user atomic function
669  CPPAD_ASSERT_NARG_NRES(op, 1, 0);
670  CPPAD_ASSERT_UNKNOWN( user_state == ret_user );
671  CPPAD_ASSERT_UNKNOWN( user_i < user_m );
672  CPPAD_ASSERT_UNKNOWN( user_j == user_n );
673  CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par );
674  //
675  user_iy[user_i] = 0; // special variable user for parameters
676 # if CPPAD_FOR_JAC_SWEEP_TRACE
677  // remember argument for delayed tracing
678  user_usrrp[user_i] = arg[0];
679 # endif
680  ++user_i;
681  if( user_i == user_m )
682  user_state = end_user;
683  break;
684 
685  case UsrrvOp:
686  // variable result for a user atomic function
687  CPPAD_ASSERT_NARG_NRES(op, 0, 1);
688  CPPAD_ASSERT_UNKNOWN( user_state == ret_user );
689  CPPAD_ASSERT_UNKNOWN( user_i < user_m );
690  CPPAD_ASSERT_UNKNOWN( user_j == user_n );
691  //
692  user_iy[user_i] = i_var; // variable index for this result
693  //
694  ++user_i;
695  if( user_i == user_m )
696  user_state = end_user;
697  break;
698  // -------------------------------------------------
699 
700  case ZmulpvOp:
701  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
703  i_var, arg[1], var_sparsity
704  );
705  break;
706  // -------------------------------------------------
707 
708  case ZmulvpOp:
709  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
711  i_var, arg[0], var_sparsity
712  );
713  break;
714  // -------------------------------------------------
715 
716  case ZmulvvOp:
717  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
719  i_var, arg, var_sparsity
720  );
721  break;
722  // -------------------------------------------------
723 
724  default:
726  }
727 # if CPPAD_FOR_JAC_SWEEP_TRACE
728  if( op == UserOp && user_state == start_user )
729  { // print operators that have been delayed
730  CPPAD_ASSERT_UNKNOWN( user_m == user_iy.size() );
731  CPPAD_ASSERT_UNKNOWN( i_op > user_m );
734  addr_t arg_tmp[1];
735  for(i = 0; i < user_m; i++)
736  { size_t j_var = user_iy[i];
737  // value for this variable
738  for(j = 0; j < limit; j++)
739  z_value[j] = false;
740  typename Vector_set::const_iterator itr(var_sparsity, j_var);
741  j = *itr;
742  while( j < limit )
743  { z_value[j] = true;
744  j = *(++itr);
745  }
746  OpCode op_tmp = UsrrvOp;
747  if( j_var == 0 )
748  { op_tmp = UsrrpOp;
749  arg_tmp[0] = user_usrrp[i];
750  }
751  // j_var is zero when there is no result.
752  printOp(
753  std::cout,
754  play,
755  i_op - user_m + i,
756  j_var,
757  op_tmp,
758  arg_tmp
759  );
760  if( j_var > 0 ) printOpResult(
761  std::cout,
762  1,
763  &z_value,
764  0,
765  (CppAD::vectorBool *) CPPAD_NULL
766  );
767  std::cout << std::endl;
768  }
769  }
770  // value for this variable
771  for(j = 0; j < limit; j++)
772  z_value[j] = false;
773  typename Vector_set::const_iterator itr(var_sparsity, i_var);
774  j = *itr;
775  while( j < limit )
776  { z_value[j] = true;
777  j = *(++itr);
778  }
779  // must delay print for these cases till after atomic user call
780  bool delay_print = op == UsrrpOp;
781  delay_print |= op == UsrrvOp;
782  if( ! delay_print )
783  { printOp(
784  std::cout,
785  play,
786  i_op,
787  i_var,
788  op,
789  arg
790  );
791  if( NumRes(op) > 0 && (! delay_print) ) printOpResult(
792  std::cout,
793  1,
794  &z_value,
795  0,
796  (CppAD::vectorBool *) CPPAD_NULL
797  );
798  std::cout << std::endl;
799  }
800  }
801  std::cout << std::endl;
802 # else
803  }
804 # endif
805 
806  return;
807 }
808 
809 } } // END_CPPAD_LOCAL_NAMESPACE
810 
811 // preprocessor symbols that are local to this file
812 # undef CPPAD_FOR_JAC_SWEEP_TRACE
813 
814 # endif
void forward_sparse_jacobian_cond_op(bool dependency, size_t i_z, const addr_t *arg, size_t num_par, Vector_set &sparsity)
Compute forward Jacobian sparsity patterns for op = CExpOp.
Definition: cond_op.hpp:981
void resize(size_t n)
resize the vector (existing elements preserved when n &lt;= capacity_).
Definition: pod_vector.hpp:180
size_t num_par_rec(void) const
Fetch number of parameters in the recording.
Definition: player.hpp:638
size_t extend(size_t n)
Increase the number of elements the end of this vector (existing elements are always preserved)...
Definition: pod_vector.hpp:115
void printOpResult(std::ostream &os, size_t nfz, const Value *fz, size_t nrz, const Value *rz)
Prints the result values correspnding to an operator.
Definition: op_code.hpp:852
size_t num_vec_ind_rec(void) const
Fetch number of VecAD indices in the recording.
Definition: player.hpp:626
CPPAD_TAPE_ADDR_TYPE addr_t
Definition: declare_ad.hpp:44
static Float quiet_NaN(void)
not a number
next UsrrpOp (UsrrvOp) is a parameter (variable) result
Definition: user_state.hpp:25
void forward_sparse_jacobian_csum_op(size_t i_z, const addr_t *arg, Vector_set &sparsity)
Forward mode Jacobian sparsity pattern for CSumOp operator.
Definition: csum_op.hpp:425
size_t NumArg(OpCode op)
Number of arguments for a specified operator.
Definition: op_code.hpp:175
Class used to store and play back an operation sequence recording.
Definition: declare_ad.hpp:27
size_t GetVecInd(size_t i) const
Fetch a VecAD index from the recording.
Definition: player.hpp:571
void forward_sparse_load_op(bool dependency, OpCode op, size_t i_z, const addr_t *arg, size_t num_combined, const size_t *combined, Vector_set &var_sparsity, Vector_set &vecad_sparsity)
Forward mode sparsity operations for LdpOp and LdvOp.
Definition: load_op.hpp:584
void resize(size_t n)
change the number of elements in this vector.
Definition: vector.hpp:399
size_t NumRes(OpCode op)
Number of variables resulting from the specified operation.
Definition: op_code.hpp:281
File used to define pod_vector class.
next UserOp marks end of a user atomic call
Definition: user_state.hpp:28
atomic_base< Base > * get_user_info(const OpCode op, const addr_t *op_arg, size_t &user_old, size_t &user_m, size_t &user_n) const
unpack extra information corresponding to a UserOp
Definition: player.hpp:517
virtual void set_old(size_t id)
Set value of id (used by deprecated old_atomic class)
size_t size(void) const
number of elements currently in this vector.
Definition: vector.hpp:387
OpCode
Type used to distinguish different AD&lt; Base &gt; atomic operations.
Definition: op_code.hpp:49
next UserOp marks beginning of a user atomic call
Definition: user_state.hpp:19
void get_op_info(size_t op_index, OpCode &op, const addr_t *&op_arg, size_t &var_index) const
fetch the information corresponding to an operator
Definition: player.hpp:485
size_t num_vecad_vec_rec(void) const
Fetch number of VecAD vectors in the recording.
Definition: player.hpp:630
Type * data(void)
current data pointer is no longer valid after any of the following: extend, erase, operator=, and ~pod_vector. Take extreem care when using this function.
Definition: pod_vector.hpp:89
next UsrapOp (UsravOp) is a parameter (variable) argument
Definition: user_state.hpp:22
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
void forward_sparse_jacobian_unary_op(size_t i_z, size_t i_x, Vector_set &sparsity)
Forward mode Jacobian sparsity pattern for all unary operators.
void printOp(std::ostream &os, const local::player< Base > *play, size_t i_op, size_t i_var, OpCode op, const addr_t *ind)
Prints a single operator and its operands.
Definition: op_code.hpp:547
#define CPPAD_ASSERT_NARG_NRES(op, n_arg, n_res)
Check that operator op has the specified number of of arguments and results.
void forward_sparse_store_op(bool dependency, OpCode op, const addr_t *arg, size_t num_combined, const size_t *combined, Vector_set &var_sparsity, Vector_set &vecad_sparsity)
Forward mode sparsity operations for StpvOp and StvvOp.
Definition: store_op.hpp:352
void forward_sparse_jacobian_binary_op(size_t i_z, const addr_t *arg, Vector_set &sparsity)
Forward mode Jacobian sparsity pattern for all binary operators.
virtual bool for_sparse_jac(size_t q, const vector< std::set< size_t > > &r, vector< std::set< size_t > > &s, const vector< Base > &x)
Link, after case split, from for_jac_sweep to atomic_base.
Base GetPar(size_t i) const
Fetch a parameter from the recording.
Definition: player.hpp:584
void for_jac_sweep(const local::player< Base > *play, bool dependency, size_t n, size_t numvar, Vector_set &var_sparsity)
Given the sparsity pattern for the independent variables, ForJacSweep computes the sparsity pattern f...
size_t num_var_rec(void) const
Fetch number of variables in the recording.
Definition: player.hpp:614