CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
vec_ad.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_CORE_VEC_AD_HPP
2 # define CPPAD_CORE_VEC_AD_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 $begin VecAD$$
16 $spell
17  cppad.hpp
18  CondExpGt
19  grep
20  Ld
21  vp
22  Lu
23  wc
24  op
25  Ldp
26  Ldv
27  Taylor
28  VecAD
29  const
30  Cpp
31 $$
32 
33 
34 $section AD Vectors that Record Index Operations$$
35 $mindex VecAD tape reference VecAD<Base>$$
36 
37 
38 $head Syntax$$
39 $codei%VecAD<%Base%> %v%(%n%)%$$
40 $pre
41 $$
42 $icode%v%.size()%$$
43 $pre
44 $$
45 $icode%b% = %v%[%i%]%$$
46 $pre
47 $$
48 $icode%r% = %v%[%x%]%$$
49 
50 $head Purpose$$
51 If either $icode v$$ or $icode x$$ is a
52 $cref/variable/glossary/Variable/$$,
53 the indexing operation
54 $codei%
55  %r% = %v%[%x%]
56 %$$
57 is recorded in the corresponding
58 AD of $icode Base$$
59 $cref/operation sequence/glossary/Operation/Sequence/$$ and
60 transferred to the corresponding $cref ADFun$$ object $icode f$$.
61 Such an index can change each time
62 zero order $cref/f.Forward/Forward/$$ is used; i.e.,
63 $icode f$$ is evaluated with new value for the
64 $cref/independent variables/glossary/Tape/Independent Variable/$$.
65 Note that the value of $icode y$$ depends on the value of $icode x$$
66 in a discrete fashion and CppAD computes its partial derivative with
67 respect to $icode x$$ as zero.
68 
69 $head Alternatives$$
70 If only the values in the vector,
71 and not the indices,
72 depend on the independent variables,
73 the class $icode%Vector%< AD<%Base%> >%$$ is much more efficient for
74 storing AD values where $icode Vector$$ is any
75 $cref SimpleVector$$ template class,
76 If only the indices,
77 and not the values in the vector,
78 depend on the independent variables,
79 The $cref Discrete$$ functions are a much more efficient
80 way to represent these vectors.
81 
82 $head VecAD<Base>::reference$$
83 The result $icode r$$ has type
84 $codei%
85  VecAD<%Base%>::reference
86 %$$
87 which is very much like the $codei%AD<%Base%>%$$ type
88 with some notable exceptions:
89 
90 $subhead Exceptions$$
91 $list number$$
92 The object $icode r$$ cannot be used with the
93 $cref Value$$ function to compute the corresponding $icode Base$$ value.
94 If $icode v$$ and $icode i$$ are not $cref/variables/glossary/Variable/$$
95 $codei%
96  %b% = v[%i%]
97 %$$
98 can be used to compute the corresponding $icode Base$$ value.
99 
100 $lnext
101 The object $icode r$$ cannot be used
102 with the $cref/compound assignments operators/Arithmetic/$$
103 $code +=$$,
104 $code -=$$,
105 $code *=$$, or
106 $code /=$$.
107 For example, the following syntax is not valid:
108 $codei%
109  %v%[%x%] += %z%;
110 %$$
111 no matter what the types of $icode z$$.
112 
113 $lnext
114 Assignment to $icode r$$ returns a $code void$$.
115 For example, the following syntax is not valid:
116 $codei%
117  %z% = %v%[%x%] = %u%;
118 %$$
119 no matter what the types of $icode z$$, and $icode u$$.
120 
121 $lnext
122 The $cref CondExp$$ functions do not accept
123 $codei%VecAD<%Base%>::reference%$$ arguments.
124 For example, the following syntax is not valid:
125 $codei%
126  CondExpGt(%v%[%x%], %z%, %u%, %v%)
127 %$$
128 no matter what the types of $icode z$$, $icode u$$, and $icode v$$.
129 
130 $lnext
131 The $cref/Parameter and Variable/ParVar/$$ functions cannot be used with
132 $codei%VecAD<%Base%>::reference%$$ arguments like $icode r$$,
133 use the entire $codei%VecAD<%Base%>%$$ vector instead; i.e. $icode v$$.
134 
135 $lnext
136 The vectors passed to $cref Independent$$ must have elements
137 of type $codei%AD<%Base%>%$$; i.e., $cref VecAD$$ vectors
138 cannot be passed to $code Independent$$.
139 
140 $lnext
141 If one uses this type in a
142 AD of $icode Base$$
143 $cref/operation sequence/glossary/Operation/Sequence/$$,
144 $cref/sparsity pattern/glossary/Sparsity Pattern/$$ calculations
145 ($cref sparsity_pattern$$)
146 are less efficient because the dependence of different
147 elements of the vector cannot be separated.
148 
149 $lend
150 
151 $head Constructor$$
152 
153 $subhead v$$
154 The syntax
155 $codei%
156  VecAD<%Base%> %v%(%n%)
157 %$$
158 creates an $code VecAD$$ object $icode v$$ with
159 $icode n$$ elements.
160 The initial value of the elements of $icode v$$ is unspecified.
161 
162 $head n$$
163 The argument $icode n$$ has prototype
164 $codei%
165  size_t %n%
166 %$$
167 
168 $head size$$
169 The syntax
170 $codei%
171  %v%.size()
172 %$$
173 returns the number of elements in the vector $icode v$$;
174 i.e., the value of $icode n$$ when it was constructed.
175 
176 $head size_t Indexing$$
177 We refer to the syntax
178 $codei%
179  %b% = %v%[%i%]
180 %$$
181 as $code size_t$$ indexing of a $code VecAD$$ object.
182 This indexing is only valid if the vector $icode v$$ is a
183 $cref/parameter/ParVar/$$; i.e.,
184 it does not depend on the independent variables.
185 
186 $subhead i$$
187 The operand $icode i$$ has prototype
188 $codei%
189  size_t %i%
190 %$$
191 It must be greater than or equal zero
192 and less than $icode n$$; i.e., less than
193 the number of elements in $icode v$$.
194 
195 $subhead b$$
196 The result $icode b$$ has prototype
197 $codei%
198  %Base% %b%
199 %$$
200 and is a reference to the $th i$$ element in the vector $icode v$$.
201 It can be used to change the element value;
202 for example,
203 $codei%
204  %v%[%i%] = %c%
205 %$$
206 is valid where $icode c$$ is a $icode Base$$ object.
207 The reference $icode b$$ is no longer valid once the
208 destructor for $icode v$$ is called; for example,
209 when $icode v$$ falls out of scope.
210 
211 $head AD Indexing$$
212 We refer to the syntax
213 $codei%
214  %r% = %v%[%x%]
215 %$$
216 as AD indexing of a $code VecAD$$ object.
217 
218 $subhead x$$
219 The argument $icode x$$ has prototype
220 $codei%
221  const AD<%Base%> &%x%
222 %$$
223 The value of $icode x$$ must be greater than or equal zero
224 and less than $icode n$$; i.e., less than
225 the number of elements in $icode v$$.
226 
227 $subhead r$$
228 The result $icode r$$ has prototype
229 $codei%
230  VecAD<%Base%>::reference %r%
231 %$$
232 The object $icode r$$ has an AD type and its
233 operations are recorded as part of the same
234 AD of $icode Base$$
235 $cref/operation sequence/glossary/Operation/Sequence/$$ as
236 for $codei%AD<%Base%>%$$ objects.
237 It acts as a reference to the
238 element with index $latex {\rm floor} (x)$$ in the vector $icode v$$
239 ($latex {\rm floor} (x)$$ is
240 the greatest integer less than or equal $icode x$$).
241 Because it is a reference, it can be used to change the element value;
242 for example,
243 $codei%
244  %v%[%x%] = %z%
245 %$$
246 is valid where $icode z$$ is an
247 $codei%VecAD<%Base%>::reference%$$ object.
248 As a reference, $icode r$$ is no longer valid once the
249 destructor for $icode v$$ is called; for example,
250 when $icode v$$ falls out of scope.
251 
252 $head Example$$
253 $children%
254  example/general/vec_ad.cpp
255 %$$
256 The file
257 $cref vec_ad.cpp$$
258 contains an example and test using $code VecAD$$ vectors.
259 It returns true if it succeeds and false otherwise.
260 
261 
262 $head Speed and Memory$$
263 The $cref VecAD$$ vector type is inefficient because every
264 time an element of a vector is accessed, a new CppAD
265 $cref/variable/glossary/Variable/$$ is created on the tape
266 using either the $code Ldp$$ or $code Ldv$$ operation
267 (unless all of the elements of the vector are
268 $cref/parameters/glossary/Parameter/$$).
269 The effect of this can be seen by executing the following steps:
270 
271 $list number$$
272 In the file $code cppad/local/forward1sweep.h$$,
273 change the definition of $code CPPAD_FORWARD1SWEEP_TRACE$$ to
274 $codep
275  # define CPPAD_FORWARD1SWEEP_TRACE 1
276 $$
277 $lnext
278 In the $code Example$$ directory, execute the command
279 $codep
280  ./test_one.sh lu_vec_ad_ok.cpp lu_vec_ad.cpp -DNDEBUG > lu_vec_ad_ok.log
281 $$
282 This will write a trace of all the forward tape operations,
283 for the test case $cref lu_vec_ad_ok.cpp$$,
284 to the file $code lu_vec_ad_ok.log$$.
285 $lnext
286 In the $code Example$$ directory execute the commands
287 $codep
288  grep "op=" lu_vec_ad_ok.log | wc -l
289  grep "op=Ld[vp]" lu_vec_ad_ok.log | wc -l
290  grep "op=St[vp][vp]" lu_vec_ad_ok.log | wc -l
291 $$
292 The first command counts the number of operators in the tracing,
293 the second counts the number of VecAD load operations,
294 and the third counts the number of VecAD store operations.
295 (For CppAD version 05-11-20 these counts were 956, 348, and 118
296 respectively.)
297 $lend
298 
299 $end
300 ------------------------------------------------------------------------
301 */
302 # include <cppad/local/pod_vector.hpp>
303 
304 namespace CppAD { // BEGIN_CPPAD_NAMESPACE
305 /*!
306 \file vec_ad.hpp
307 Defines the VecAD<Base> class.
308 */
309 
310 /*!
311 \def CPPAD_VEC_AD_COMPUTED_ASSIGNMENT(op, name)
312 Prints an error message if the correspinding compound assignment is used.
313 
314 THis macro is used to print an error message if any of the
315 compound assignments are used with the VecAD_reference class.
316 The argument \c op is one of the following:
317 += , -= , *= , /=.
318 The argument \c name, is a string literal with the name of the
319 compound assignment \c op.
320 */
321 # define CPPAD_VEC_AD_COMPUTED_ASSIGNMENT(op, name) \
322 VecAD_reference& operator op (const VecAD_reference<Base> &right) \
323 { CPPAD_ASSERT_KNOWN( \
324  false, \
325  "Cannot use a ADVec element on left side of" name \
326  ); \
327  return *this; \
328 } \
329 VecAD_reference& operator op (const AD<Base> &right) \
330 { CPPAD_ASSERT_KNOWN( \
331  false, \
332  "Cannot use a ADVec element on left side of" name \
333  ); \
334  return *this; \
335 } \
336 VecAD_reference& operator op (const Base &right) \
337 { CPPAD_ASSERT_KNOWN( \
338  false, \
339  "Cannot use a ADVec element on left side of" name \
340  ); \
341  return *this; \
342 }
343 
344 /*!
345 Class used to hold a reference to an element of a VecAD object.
346 
347 \tparam Base
348 Elements of this class act like an AD<Base> (in a restricted sense),
349 in addition they track (on the tape) the index they correspond to.
350 */
351 template <class Base>
353  friend bool Parameter<Base> (const VecAD<Base> &vec);
354  friend bool Variable<Base> (const VecAD<Base> &vec);
355  friend class VecAD<Base>;
356  friend class local::ADTape<Base>;
357 
358 private:
359  /// pointer to vecad vector that this is a element of
361  /// index in vecad vector that this element corresponds to
362  AD<Base> ind_; // index for this element
363 public:
364  /*!
365  consructor
366 
367  \param vec
368  value of vec_
369 
370  \param ind
371  value of ind_
372  */
374  : vec_( vec ) , ind_(ind)
375  { }
376 
377  // assignment operators
378  inline void operator = (const VecAD_reference<Base> &right);
379  void operator = (const AD<Base> &right);
380  void operator = (const Base &right);
381  void operator = (int right);
382 
383  // compound assignments
388 
389 
390  /// Conversion from VecAD_reference to AD<Base>.
391  /// puts the correspond vecad load instruction in the tape.
392  AD<Base> ADBase(void) const
393  { AD<Base> result;
394 
395  size_t i = static_cast<size_t>( Integer(ind_) );
396  CPPAD_ASSERT_UNKNOWN( i < vec_->length_ );
397 
398  // AD<Base> value corresponding to this element
399  result.value_ = vec_->data_[i];
400 
401  // this address will be recorded in tape and must be
402  // zero for parameters
403  CPPAD_ASSERT_UNKNOWN( Parameter(result) );
404  result.taddr_ = 0;
405 
406  // index corresponding to this element
407  if( Variable(*vec_) )
408  {
409  local::ADTape<Base>* tape = AD<Base>::tape_ptr(vec_->tape_id_);
410  CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL );
411  CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 );
412 
413  size_t load_op_index = tape->Rec_.num_load_op_rec();
414  if( IdenticalPar(ind_) )
417 
418  // put operand addresses in tape
419  tape->Rec_.PutArg(
420  (addr_t) vec_->offset_, (addr_t) i, (addr_t) load_op_index
421  );
422  // put operator in the tape, ind_ is a parameter
423  result.taddr_ = tape->Rec_.PutLoadOp(local::LdpOp);
424  // change result to variable for this load
425  result.tape_id_ = tape->id_;
426  }
427  else
430  addr_t ind_taddr;
431  if( Parameter(ind_) )
432  { // kludge that should not be needed
433  // if ind_ instead of i is used for index
434  // in the tape
435  ind_taddr = tape->RecordParOp(
436  ind_.value_
437  );
438  }
439  else ind_taddr = ind_.taddr_;
440  CPPAD_ASSERT_UNKNOWN( ind_taddr > 0 );
441 
442  // put operand addresses in tape
443  tape->Rec_.PutArg(
444  (addr_t) vec_->offset_,
445  (addr_t) ind_taddr,
446  (addr_t) load_op_index
447  );
448  // put operator in the tape, ind_ is a variable
449  result.taddr_ = tape->Rec_.PutLoadOp(local::LdvOp);
450  // change result to variable for this load
451  result.tape_id_ = tape->id_;
452  }
453  }
454  return result;
455  }
456 };
457 
458 /*!
459 Vector of AD objects that tracks indexing operations on the tape.
460 */
461 template <class Base>
462 class VecAD {
463  friend bool Parameter<Base> (const VecAD<Base> &vec);
464  friend bool Variable<Base> (const VecAD<Base> &vec);
465  friend class local::ADTape<Base>;
466  friend class VecAD_reference<Base>;
467 
468  friend std::ostream& operator << <Base>
469  (std::ostream &os, const VecAD<Base> &vec_);
470 private:
471  /// size of this VecAD vector
472  const size_t length_;
473 
474  /// elements of this vector
476 
477  /// offset in cummulate vector corresponding to this object
478  size_t offset_;
479 
480  /// tape id corresponding to the offset
482 public:
483  /// declare the user's view of this type here
485 
486  /// default constructor
487  /// initialize tape_id_ same as for default constructor; see default.hpp
488  VecAD(void)
489  : length_(0)
490  , offset_(0)
491  , tape_id_(0)
492  { CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); }
493 
494  /// sizing constructor
495  /// initialize tape_id_ same as for parameters; see ad_copy.hpp
496  VecAD(size_t n)
497  : length_(n)
498  , offset_(0)
499  , tape_id_(0)
500  { if( length_ > 0 )
501  { size_t i;
502  Base zero(0);
504 
505  // Initialize data to zero so all have same value.
506  // This uses less memory and avoids a valgrind error
507  // during TapeRec<Base>::PutPar
508  for(i = 0; i < length_; i++)
509  data_[i] = zero;
510  }
512  }
513 
514  /// destructor
515  ~VecAD(void)
516  { }
517 
518  /// number of elements in the vector
519  size_t size(void)
520  { return length_; }
521 
522  /// element access (not taped)
523  ///
524  /// \param i
525  /// element index
526  Base &operator[](size_t i)
527  {
529  Parameter(*this),
530  "VecAD: cannot use size_t indexing because this"
531  " VecAD vector is a variable."
532  );
534  i < length_,
535  "VecAD: element index is >= vector length"
536  );
537 
538  return data_[i];
539  }
540 
541  /*! delayed taped elemement access
542 
543  \param x
544  element index
545 
546  \par
547  This operation may convert this vector from a parameter to a variable
548  */
550  {
552  0 <= Integer(x),
553  "VecAD: element index is less than zero"
554  );
556  static_cast<size_t>( Integer(x) ) < length_,
557  "VecAD: element index is >= vector length"
558  );
559 
560  // if no need to track indexing operation, return now
561  if( Parameter(*this) & Parameter(x) )
562  return VecAD_reference<Base>(this, x);
563 
565  Parameter(*this) | Parameter(x) | (tape_id_ == x.tape_id_),
566  "VecAD: vector and index are variables for"
567  " different tapes."
568  );
569 
570  if( Parameter(*this) )
571  { // must place a copy of vector in tape
572  offset_ =
574 
575  // Advance pointer by one so starts at first component of this
576  // vector; i.e., skip length at begining (so is always > 0)
577  offset_++;
578 
579  // tape id corresponding to this offest
580  tape_id_ = x.tape_id_;
581  }
582 
583  return VecAD_reference<Base>(this, x);
584  }
585 
586 };
587 
588 
589 /*!
590 Taped setting of element to a value.
591 
592 \param y
593 value that element is set to.
594 */
595 template <class Base>
597 {
598  if( Parameter(y) )
599  { // fold into the Base type assignment
600  *this = y.value_;
601  return;
602  }
603  CPPAD_ASSERT_UNKNOWN( y.taddr_ > 0 );
604 
606  Parameter(*vec_) | (vec_->tape_id_ == y.tape_id_),
607  "VecAD assignment: vector and new element value are variables"
608  "\nfor different tapes."
609  );
610 
612  CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL );
613  if( Parameter(*vec_) )
614  { // must place a copy of vector in tape
615  vec_->offset_ = tape->AddVec(vec_->length_, vec_->data_);
616 
617  // advance offset to be start of vector plus one
618  (vec_->offset_)++;
619 
620  // tape id corresponding to this offest
621  vec_->tape_id_ = y.tape_id_;
622  }
623  CPPAD_ASSERT_UNKNOWN( Variable(*vec_) );
624 
625 
626  // index in vector for this element
627  size_t i = static_cast<size_t>( Integer(ind_) );
628  CPPAD_ASSERT_UNKNOWN( i < vec_->length_ );
629 
630  // assign value for this element (as an AD<Base> object)
631  vec_->data_[i] = y.value_;
632 
633  // record the setting of this array element
634  CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 );
635  if( Parameter(ind_) )
638 
639  // put operand addresses in tape
640  tape->Rec_.PutArg((addr_t) vec_->offset_, (addr_t) i, y.taddr_);
641 
642  // put operator in the tape, ind_ is parameter, y is variable
643  tape->Rec_.PutOp(local::StpvOp);
644  }
645  else
648  CPPAD_ASSERT_UNKNOWN( ind_.taddr_ > 0 );
649 
650  // put operand addresses in tape
651  tape->Rec_.PutArg((addr_t) vec_->offset_, ind_.taddr_, y.taddr_);
652 
653  // put operator in the tape, ind_ is variable, y is variable
654  tape->Rec_.PutOp(local::StvvOp);
655  }
656 }
657 
658 
659 /*!
660 Taped setting of element to a value.
661 
662 \param y
663 value that element is set to.
664 */
665 template <class Base>
667 {
668  size_t i = static_cast<size_t>( Integer(ind_) );
669  CPPAD_ASSERT_UNKNOWN( i < vec_->length_ );
670 
671  // assign value for this element
672  vec_->data_[i] = y;
673 
674  // check if this ADVec object is a parameter
675  if( Parameter(*vec_) )
676  return;
677 
678  local::ADTape<Base>* tape = AD<Base>::tape_ptr(vec_->tape_id_);
679  CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL );
680 
681  // put value of the parameter y in the tape
682  addr_t p = tape->Rec_.PutPar(y);
683 
684  // record the setting of this array element
685  CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 );
686  if( Parameter(ind_) )
689 
690  // put operand addresses in tape
691  tape->Rec_.PutArg((addr_t) vec_->offset_, (addr_t) i, p);
692 
693  // put operator in the tape, ind_ is parameter, y is parameter
694  tape->Rec_.PutOp(local::StppOp);
695  }
696  else
699  CPPAD_ASSERT_UNKNOWN( ind_.taddr_ > 0 );
700 
701  // put operand addresses in tape
702  tape->Rec_.PutArg((addr_t) vec_->offset_, ind_.taddr_, p);
703 
704  // put operator in the tape, ind_ is variable, y is parameter
705  tape->Rec_.PutOp(local::StvpOp);
706  }
707 }
708 
709 /*!
710 Taped setting of element to a value.
711 
712 \param y
713 value that element is set to.
714 
715 \par
716 this case gets folded into case where value is AD<Base>.
717 */
718 template <class Base>
721 { *this = y.ADBase(); }
722 
723 /*!
724 Taped setting of element to a value.
725 
726 \param y
727 value that element is set to.
728 
729 \par
730 this case gets folded into case where value is Base.
731 */
732 template <class Base>
734 { *this = Base(y); }
735 
736 
737 } // END_CPPAD_NAMESPACE
738 
739 // preprocessor symbols that are local to this file
740 # undef CPPAD_VEC_AD_COMPUTED_ASSIGNMENT
741 
742 # endif
local::pod_vector< Base > data_
elements of this vector
Definition: vec_ad.hpp:475
addr_t RecordParOp(const Base &x)
Place a parameter in the tape.
Definition: ad_tape.hpp:160
void operator=(const VecAD_reference< Base > &right)
Taped setting of element to a value.
Definition: vec_ad.hpp:720
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
VecAD_reference< Base > operator[](const AD< Base > &x)
delayed taped elemement access
Definition: vec_ad.hpp:549
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
friend bool Variable(const VecAD< Base > &vec)
Definition: par_var.hpp:108
friend bool Parameter(const VecAD< Base > &vec)
Definition: par_var.hpp:89
friend bool Parameter(const VecAD< Base > &vec)
Definition: par_var.hpp:89
Base value_
Definition: ad.hpp:38
CPPAD_TAPE_ADDR_TYPE addr_t
Definition: declare_ad.hpp:44
Definition: ad.hpp:34
#define CPPAD_VEC_AD_COMPUTED_ASSIGNMENT(op, name)
Prints an error message if the correspinding compound assignment is used.
Definition: vec_ad.hpp:321
size_t NumArg(OpCode op)
Number of arguments for a specified operator.
Definition: op_code.hpp:175
VecAD(size_t n)
sizing constructor initialize tape_id_ same as for parameters; see ad_copy.hpp
Definition: vec_ad.hpp:496
size_t offset_
offset in cummulate vector corresponding to this object
Definition: vec_ad.hpp:478
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.
bool IdenticalPar(const std::complex< double > &x)
VecAD< Base > * vec_
pointer to vecad vector that this is a element of
Definition: vec_ad.hpp:360
~VecAD(void)
destructor
Definition: vec_ad.hpp:515
AD< Base > ADBase(void) const
Conversion from VecAD_reference to AD&lt;Base&gt;. puts the correspond vecad load instruction in the tape...
Definition: vec_ad.hpp:392
static local::ADTape< Base > * tape_ptr(void)
Pointer for the tape for this AD&lt;Base&gt; class and the current thread.
Definition: tape_link.hpp:130
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Variable(const AD< Base > &x)
Definition: par_var.hpp:99
Base & operator[](size_t i)
element access (not taped)
Definition: vec_ad.hpp:526
tape_id_t tape_id_
tape id corresponding to the offset
Definition: vec_ad.hpp:481
const size_t length_
size of this VecAD vector
Definition: vec_ad.hpp:472
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
VecAD_reference(VecAD< Base > *vec, const AD< Base > &ind)
consructor
Definition: vec_ad.hpp:373
VecAD(void)
default constructor initialize tape_id_ same as for default constructor; see default.hpp
Definition: vec_ad.hpp:488
size_t size(void)
number of elements in the vector
Definition: vec_ad.hpp:519
size_t AddVec(size_t length, const pod_vector< Base > &data)
Put initialization for a VecAD&lt;Base&gt; object in the tape.
Definition: ad_tape.hpp:198
local::recorder< Base > Rec_
This is where the information is recorded.
Definition: ad_tape.hpp:106
int Integer(const std::complex< double > &x)
tape_id_t tape_id_
Definition: ad.hpp:41
AD< Base > ind_
index in vecad vector that this element corresponds to
Definition: vec_ad.hpp:362
Class used to hold a reference to an element of a VecAD object.
Definition: vec_ad.hpp:352
Class used to hold tape that records AD&lt;Base&gt; operations.
Definition: ad_tape.hpp:26
Vector of AD objects that tracks indexing operations on the tape.
Definition: vec_ad.hpp:462
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Parameter(const AD< Base > &x)
Definition: par_var.hpp:80
addr_t taddr_
Definition: ad.hpp:44
tape_id_t id_
Unique identifier for this tape.
Definition: ad_tape.hpp:101
VecAD_reference< Base > reference
declare the user&#39;s view of this type here
Definition: vec_ad.hpp:484
CPPAD_TAPE_ID_TYPE tape_id_t
Definition: declare_ad.hpp:45