CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rev_jac_sweep.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_LOCAL_REV_JAC_SWEEP_HPP
2 # define CPPAD_LOCAL_REV_JAC_SWEEP_HPP
3 
4 /* --------------------------------------------------------------------------
5 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
6 
7 CppAD is distributed under multiple licenses. This distribution is under
8 the terms of the
9  Eclipse Public License Version 1.0.
10 
11 A copy of this license is included in the COPYING file of this distribution.
12 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
13 -------------------------------------------------------------------------- */
14 
15 namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE
16 /*!
17 \file rev_jac_sweep.hpp
18 Compute Reverse mode Jacobian sparsity patterns.
19 */
20 
21 /*!
22 \def CPPAD_REV_JAC_SWEEP_TRACE
23 This value is either zero or one.
24 Zero is the normal operational value.
25 If it is one, a trace of every rev_jac_sweep computation is printed.
26 */
27 # define CPPAD_REV_JAC_SWEEP_TRACE 0
28 
29 /*!
30 Given the sparsity pattern for the dependent variables,
31 RevJacSweep computes the sparsity pattern for all the independent variables.
32 
33 \tparam Base
34 this operation sequence was recorded using AD<Base>.
35 
36 \tparam Vector_set
37 is the type used for vectors of sets. It can be either
38 sparse_pack or sparse_list.
39 
40 \param dependency
41 Are the derivatives with respect to left and right of the expression below
42 considered to be non-zero:
43 \code
44  CondExpRel(left, right, if_true, if_false)
45 \endcode
46 This is used by the optimizer to obtain the correct dependency relations.
47 
48 \param n
49 is the number of independent variables on the tape.
50 
51 \param numvar
52 is the total number of variables on the tape; i.e.,
53 \a play->num_var_rec().
54 This is also the number of rows in the entire sparsity pattern \a RevJac.
55 
56 \param play
57 The information stored in \a play
58 is a recording of the operations corresponding to a function
59 \f[
60  F : {\bf R}^n \rightarrow {\bf R}^m
61 \f]
62 where \f$ n \f$ is the number of independent variables
63 and \f$ m \f$ is the number of dependent variables.
64 
65 \param var_sparsity
66 For i = 0 , ... , \a numvar - 1,
67 (all the variables on the tape)
68 the forward Jacobian sparsity pattern for variable i
69 corresponds to the set with index i in \a var_sparsity.
70 \b
71 \b
72 \b Input:
73 For i = 0 , ... , \a numvar - 1,
74 the forward Jacobian sparsity pattern for variable i is an input
75 if i corresponds to a dependent variable.
76 Otherwise the sparsity patten is empty.
77 \n
78 \n
79 \b Output: For j = 1 , ... , \a n,
80 the sparsity pattern for the dependent variable with index (j-1)
81 is given by the set with index index j in \a var_sparsity.
82 */
83 
84 template <class Base, class Vector_set>
86  const local::player<Base>* play,
87  bool dependency,
88  size_t n,
89  size_t numvar,
90  Vector_set& var_sparsity
91 )
92 {
93  OpCode op;
94  size_t i_op;
95  size_t i_var;
96 
97  const addr_t* arg = CPPAD_NULL;
98 
99  size_t i, j, k;
100 
101  // length of the parameter vector (used by CppAD assert macros)
102  const size_t num_par = play->num_par_rec();
103 
104  // check numvar argument
105  CPPAD_ASSERT_UNKNOWN( numvar > 0 );
106  CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar );
107  CPPAD_ASSERT_UNKNOWN( var_sparsity.n_set() == numvar );
108 
109  // upper limit (exclusive) for elements in the set
110  size_t limit = var_sparsity.end();
111 
112  // vecad_sparsity contains a sparsity pattern for each VecAD object.
113  // vecad_ind maps a VecAD index (beginning of the VecAD object)
114  // to the index of the corresponding set in vecad_sparsity.
115  size_t num_vecad_ind = play->num_vec_ind_rec();
116  size_t num_vecad_vec = play->num_vecad_vec_rec();
117  Vector_set vecad_sparsity;
118  pod_vector<size_t> vecad_ind;
119  if( num_vecad_vec > 0 )
120  { size_t length;
121  vecad_sparsity.resize(num_vecad_vec, limit);
122  vecad_ind.extend(num_vecad_ind);
123  j = 0;
124  for(i = 0; i < num_vecad_vec; i++)
125  { // length of this VecAD
126  length = play->GetVecInd(j);
127  // set to proper index for this VecAD
128  vecad_ind[j] = i;
129  for(k = 1; k <= length; k++)
130  vecad_ind[j+k] = num_vecad_vec; // invalid index
131  // start of next VecAD
132  j += length + 1;
133  }
134  CPPAD_ASSERT_UNKNOWN( j == play->num_vec_ind_rec() );
135  }
136 
137  // ----------------------------------------------------------------------
138  // user's atomic op calculator
139  atomic_base<Base>* user_atom = CPPAD_NULL; // user's atomic op calculator
140  //
141  // work space used by UserOp.
142  vector<Base> user_x; // parameters in x as integers
143  vector<size_t> user_ix; // variable indices for argument vector
144  vector<size_t> user_iy; // variable indices for result vector
145  //
146  // information set by forward_user (initialization to avoid warnings)
147  size_t user_old=0, user_m=0, user_n=0, user_i=0, user_j=0;
148  // information set by forward_user (necessary initialization)
149  enum_user_state user_state = end_user; // proper initialization
150  // ----------------------------------------------------------------------
151  //
152  // pointer to the beginning of the parameter vector
153  // (used by atomic functions
154  const Base* parameter = CPPAD_NULL;
155  if( num_par > 0 )
156  parameter = play->GetPar();
157  //
158  // Initialize
159  i_op = play->num_op_rec();
160  play->get_op_info(--i_op, op, arg, i_var);
161  CPPAD_ASSERT_UNKNOWN( op == EndOp );
162 # if CPPAD_REV_JAC_SWEEP_TRACE
163  std::cout << std::endl;
164  CppAD::vectorBool z_value(limit);
165 # endif
166  bool more_operators = true;
167  while(more_operators)
168  { bool flag; // temporary for use in switch cases
169  //
170  // next op
171  play->get_op_info(--i_op, op, arg, i_var);
172 
173  // rest of information depends on the case
174  switch( op )
175  {
176  case AbsOp:
177  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
179  i_var, arg[0], var_sparsity
180  );
181  break;
182  // -------------------------------------------------
183 
184  case AddvvOp:
185  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
187  i_var, arg, var_sparsity
188  );
189  break;
190  // -------------------------------------------------
191 
192  case AddpvOp:
193  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
195  i_var, arg[1], var_sparsity
196  );
197  break;
198  // -------------------------------------------------
199 
200  case AcosOp:
201  // sqrt(1 - x * x), acos(x)
202  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
204  i_var, arg[0], var_sparsity
205  );
206  break;
207  // -------------------------------------------------
208 
209 # if CPPAD_USE_CPLUSPLUS_2011
210  case AcoshOp:
211  // sqrt(x * x - 1), acosh(x)
212  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
214  i_var, arg[0], var_sparsity
215  );
216  break;
217 # endif
218  // -------------------------------------------------
219 
220  case AsinOp:
221  // sqrt(1 - x * x), asin(x)
222  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
224  i_var, arg[0], var_sparsity
225  );
226  break;
227  // -------------------------------------------------
228 
229 # if CPPAD_USE_CPLUSPLUS_2011
230  case AsinhOp:
231  // sqrt(1 + x * x), asinh(x)
232  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
234  i_var, arg[0], var_sparsity
235  );
236  break;
237 # endif
238  // -------------------------------------------------
239 
240  case AtanOp:
241  // 1 + x * x, atan(x)
242  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
244  i_var, arg[0], var_sparsity
245  );
246  break;
247  // -------------------------------------------------
248 
249 # if CPPAD_USE_CPLUSPLUS_2011
250  case AtanhOp:
251  // 1 - x * x, atanh(x)
252  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
254  i_var, arg[0], var_sparsity
255  );
256  break;
257 # endif
258  // -------------------------------------------------
259 
260  case BeginOp:
261  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
262  more_operators = false;
263  break;
264  // -------------------------------------------------
265 
266  case CSkipOp:
267  break;
268  // -------------------------------------------------
269 
270  case CSumOp:
272  i_var, arg, var_sparsity
273  );
274  break;
275  // -------------------------------------------------
276 
277  case CExpOp:
279  dependency, i_var, arg, num_par, var_sparsity
280  );
281  break;
282  // ---------------------------------------------------
283 
284  case CosOp:
285  // sin(x), cos(x)
286  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
288  i_var, arg[0], var_sparsity
289  );
290  break;
291  // ---------------------------------------------------
292 
293  case CoshOp:
294  // sinh(x), cosh(x)
295  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
297  i_var, arg[0], var_sparsity
298  );
299  break;
300  // -------------------------------------------------
301 
302  case DisOp:
303  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
304  // derivative is identically zero but dependency is not
305  if( dependency ) reverse_sparse_jacobian_unary_op(
306  i_var, arg[1], var_sparsity
307  );
308  break;
309  // -------------------------------------------------
310 
311  case DivvvOp:
312  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
314  i_var, arg, var_sparsity
315  );
316  break;
317  // -------------------------------------------------
318 
319  case DivpvOp:
320  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
322  i_var, arg[1], var_sparsity
323  );
324  break;
325  // -------------------------------------------------
326 
327  case DivvpOp:
328  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
330  i_var, arg[0], var_sparsity
331  );
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  break;
366  // -------------------------------------------------
367 
368  case LdpOp:
370  dependency,
371  op,
372  i_var,
373  arg,
374  num_vecad_ind,
375  vecad_ind.data(),
376  var_sparsity,
377  vecad_sparsity
378  );
379  break;
380  // -------------------------------------------------
381 
382  case LdvOp:
384  dependency,
385  op,
386  i_var,
387  arg,
388  num_vecad_ind,
389  vecad_ind.data(),
390  var_sparsity,
391  vecad_sparsity
392  );
393  break;
394  // -------------------------------------------------
395 
396  case EqpvOp:
397  case EqvvOp:
398  case LtpvOp:
399  case LtvpOp:
400  case LtvvOp:
401  case LepvOp:
402  case LevpOp:
403  case LevvOp:
404  case NepvOp:
405  case NevvOp:
406  CPPAD_ASSERT_NARG_NRES(op, 2, 0);
407  break;
408  // -------------------------------------------------
409 
410  case LogOp:
411  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
413  i_var, arg[0], var_sparsity
414  );
415  break;
416  // -------------------------------------------------
417 
418 # if CPPAD_USE_CPLUSPLUS_2011
419  case Log1pOp:
420  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
422  i_var, arg[0], var_sparsity
423  );
424  break;
425 # endif
426  // -------------------------------------------------
427 
428  case MulpvOp:
429  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
431  i_var, arg[1], var_sparsity
432  );
433  break;
434  // -------------------------------------------------
435 
436  case MulvvOp:
437  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
439  i_var, arg, var_sparsity
440  );
441  break;
442  // -------------------------------------------------
443 
444  case ParOp:
445  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
446 
447  break;
448  // -------------------------------------------------
449 
450  case PowvpOp:
452  i_var, arg[0], var_sparsity
453  );
454  break;
455  // -------------------------------------------------
456 
457  case PowpvOp:
458  CPPAD_ASSERT_NARG_NRES(op, 2, 3);
460  i_var, arg[1], var_sparsity
461  );
462  break;
463  // -------------------------------------------------
464 
465  case PowvvOp:
466  CPPAD_ASSERT_NARG_NRES(op, 2, 3);
468  i_var, arg, var_sparsity
469  );
470  break;
471  // -------------------------------------------------
472 
473  case PriOp:
474  CPPAD_ASSERT_NARG_NRES(op, 5, 0);
475  break;
476  // -------------------------------------------------
477 
478  case SignOp:
479  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
480  // derivative is identically zero but dependency is not
481  if( dependency ) reverse_sparse_jacobian_unary_op(
482  i_var, arg[0], var_sparsity
483  );
484  break;
485  // -------------------------------------------------
486 
487  case SinOp:
488  // cos(x), sin(x)
489  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
491  i_var, arg[0], var_sparsity
492  );
493  break;
494  // -------------------------------------------------
495 
496  case SinhOp:
497  // cosh(x), sinh(x)
498  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
500  i_var, arg[0], var_sparsity
501  );
502  break;
503  // -------------------------------------------------
504 
505  case SqrtOp:
506  CPPAD_ASSERT_NARG_NRES(op, 1, 1);
508  i_var, arg[0], var_sparsity
509  );
510  break;
511  // -------------------------------------------------
512 
513  case StppOp:
514  // does not affect sparsity or dependency when both are parameters
515  CPPAD_ASSERT_NARG_NRES(op, 3, 0);
516  break;
517  // -------------------------------------------------
518 
519  case StpvOp:
521  dependency,
522  op,
523  arg,
524  num_vecad_ind,
525  vecad_ind.data(),
526  var_sparsity,
527  vecad_sparsity
528  );
529  break;
530  // -------------------------------------------------
531 
532  case StvpOp:
533  CPPAD_ASSERT_NARG_NRES(op, 3, 0);
534  // storing a parameter only affects dependency
536  dependency,
537  op,
538  arg,
539  num_vecad_ind,
540  vecad_ind.data(),
541  var_sparsity,
542  vecad_sparsity
543  );
544  break;
545  // -------------------------------------------------
546 
547  case StvvOp:
549  dependency,
550  op,
551  arg,
552  num_vecad_ind,
553  vecad_ind.data(),
554  var_sparsity,
555  vecad_sparsity
556  );
557  break;
558  // -------------------------------------------------
559 
560  case SubvvOp:
561  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
563  i_var, arg, var_sparsity
564  );
565  break;
566  // -------------------------------------------------
567 
568  case SubpvOp:
569  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
571  i_var, arg[1], var_sparsity
572  );
573  break;
574  // -------------------------------------------------
575 
576  case SubvpOp:
577  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
579  i_var, arg[0], var_sparsity
580  );
581  break;
582  // -------------------------------------------------
583 
584  case TanOp:
585  // tan(x)^2, tan(x)
586  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
588  i_var, arg[0], var_sparsity
589  );
590  break;
591  // -------------------------------------------------
592 
593  case TanhOp:
594  // tanh(x)^2, tanh(x)
595  CPPAD_ASSERT_NARG_NRES(op, 1, 2);
597  i_var, arg[0], var_sparsity
598  );
599  break;
600  // -------------------------------------------------
601 
602  case UserOp:
603  // start or end an atomic function call
605  user_state == start_user || user_state == end_user
606  );
607  flag = user_state == end_user;
608  user_atom = play->get_user_info(op, arg, user_old, user_m, user_n);
609  if( flag )
610  { user_state = ret_user;
611  user_i = user_m;
612  user_j = user_n;
613  //
614  user_x.resize( user_n );
615  user_ix.resize( user_n );
616  user_iy.resize( user_m );
617  }
618  else
619  { user_state = end_user;
620  //
621  user_atom->set_old(user_old);
622  user_atom->rev_sparse_jac(
623  user_x, user_ix, user_iy, var_sparsity
624  );
625  }
626  break;
627 
628  case UsrapOp:
629  // parameter argument in an atomic operation sequence
630  CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 );
631  CPPAD_ASSERT_UNKNOWN( user_state == arg_user );
632  CPPAD_ASSERT_UNKNOWN( user_i == 0 );
633  CPPAD_ASSERT_UNKNOWN( user_j <= user_n );
634  CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par );
635  //
636  --user_j;
637  // argument parameter value
638  user_x[user_j] = parameter[arg[0]];
639  // special variable index used for parameters
640  user_ix[user_j] = 0;
641  //
642  if( user_j == 0 )
643  user_state = start_user;
644  break;
645 
646  case UsravOp:
647  // variable argument in an atomic operation sequence
648  CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 );
649  CPPAD_ASSERT_UNKNOWN( user_state == arg_user );
650  CPPAD_ASSERT_UNKNOWN( user_i == 0 );
651  CPPAD_ASSERT_UNKNOWN( user_j <= user_n );
652  //
653  --user_j;
654  // argument variables not available during sparsity calculations
655  user_x[user_j] = CppAD::numeric_limits<Base>::quiet_NaN();
656  // variable index for this argument
657  user_ix[user_j] = arg[0];
658  //
659  if( user_j == 0 )
660  user_state = start_user;
661  break;
662 
663  case UsrrpOp:
664  // parameter result for a user atomic function
665  CPPAD_ASSERT_NARG_NRES(op, 1, 0);
666  CPPAD_ASSERT_UNKNOWN( user_state == ret_user );
667  CPPAD_ASSERT_UNKNOWN( user_i <= user_m );
668  CPPAD_ASSERT_UNKNOWN( user_j == user_n );
669  CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par );
670  //
671  --user_i;
672  user_iy[user_i] = 0; // special variable used for parameters
673  //
674  if( user_i == 0 )
675  user_state = arg_user;
676  break;
677 
678  case UsrrvOp:
679  // variable result for a user atomic function
680  CPPAD_ASSERT_NARG_NRES(op, 0, 1);
681  CPPAD_ASSERT_UNKNOWN( user_state == ret_user );
682  CPPAD_ASSERT_UNKNOWN( user_i <= user_m );
683  CPPAD_ASSERT_UNKNOWN( user_j == user_n );
684  //
685  --user_i;
686  user_iy[user_i] = i_var; // variable for this result
687  //
688  if( user_i == 0 )
689  user_state = arg_user;
690  break;
691  // -------------------------------------------------
692 
693  case ZmulpvOp:
694  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
696  i_var, arg[1], var_sparsity
697  );
698  break;
699  // -------------------------------------------------
700 
701  case ZmulvpOp:
702  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
704  i_var, arg[0], var_sparsity
705  );
706  break;
707  // -------------------------------------------------
708 
709  case ZmulvvOp:
710  CPPAD_ASSERT_NARG_NRES(op, 2, 1);
712  i_var, arg, var_sparsity
713  );
714  break;
715  // -------------------------------------------------
716 
717  default:
719  }
720 # if CPPAD_REV_JAC_SWEEP_TRACE
721  for(j = 0; j < limit; j++)
722  z_value[j] = false;
723  typename Vector_set::const_iterator itr(var_sparsity, i_var);
724  j = *itr;
725  while( j < limit )
726  { z_value[j] = true;
727  j = *(++itr);
728  }
729  printOp(
730  std::cout,
731  play,
732  i_op,
733  i_var,
734  op,
735  arg
736  );
737  // Note that sparsity for UsrrvOp are computed before call to
738  // atomic function so no need to delay printing (as in forward mode)
739  if( NumRes(op) > 0 && op != BeginOp ) printOpResult(
740  std::cout,
741  0,
742  (CppAD::vectorBool *) CPPAD_NULL,
743  1,
744  &z_value
745  );
746  std::cout << std::endl;
747  }
748  std::cout << std::endl;
749 # else
750  }
751 # endif
752  // values corresponding to BeginOp
753  CPPAD_ASSERT_UNKNOWN( i_op == 0 );
754  CPPAD_ASSERT_UNKNOWN( i_var == 0 );
755 
756  return;
757 }
758 } } // END_CPPAD_LOCAL_NAMESPACE
759 
760 // preprocessor symbols that are local to this file
761 # undef CPPAD_REV_JAC_SWEEP_TRACE
762 # undef CPPAD_ATOMIC_CALL
763 
764 # endif
virtual bool rev_sparse_jac(size_t q, const vector< std::set< size_t > > &rt, vector< std::set< size_t > > &st, const vector< Base > &x)
Link, after case split, from rev_jac_sweep to atomic_base.
void reverse_sparse_jacobian_cond_op(bool dependency, size_t i_z, const addr_t *arg, size_t num_par, Vector_set &sparsity)
Compute reverse Jacobian sparsity patterns for op = CExpOp.
Definition: cond_op.hpp:1122
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
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 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
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)
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
void reverse_sparse_jacobian_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)
Reverse mode sparsity operations for StpvOp, StvpOp, and StvvOp.
Definition: store_op.hpp:408
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
void reverse_sparse_jacobian_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)
Reverse mode Jacobian sparsity operations for LdpOp and LdvOp.
Definition: load_op.hpp:618
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
void reverse_sparse_jacobian_csum_op(size_t i_z, const addr_t *arg, Vector_set &sparsity)
Reverse mode Jacobian sparsity pattern for CSumOp operator.
Definition: csum_op.hpp:502
size_t num_op_rec(void) const
Fetch number of operators in the recording.
Definition: player.hpp:622
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 reverse_sparse_jacobian_binary_op(size_t i_z, const addr_t *arg, Vector_set &sparsity)
Reverse mode Jacobian sparsity pattern for all binary operators.
Base GetPar(size_t i) const
Fetch a parameter from the recording.
Definition: player.hpp:584
void rev_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 dependent variables, RevJacSweep computes the sparsity pattern for...
void reverse_sparse_jacobian_unary_op(size_t i_z, size_t i_x, Vector_set &sparsity)
Reverse mode Jacobian sparsity pattern for all unary operators.
size_t num_var_rec(void) const
Fetch number of variables in the recording.
Definition: player.hpp:614