CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
var2par.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_CORE_VAR2PAR_HPP
2 # define CPPAD_CORE_VAR2PAR_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 /*
16 ------------------------------------------------------------------------------
17 
18 $begin Var2Par$$
19 $spell
20  var
21  const
22 $$
23 
24 
25 $section Convert an AD Variable to a Parameter$$
26 $mindex Var2Par from value_ obtain during taping$$
27 
28 $head Syntax$$
29 $icode%y% = Var2Par(%x%)%$$
30 
31 $head See Also$$
32 $cref value$$
33 
34 
35 $head Purpose$$
36 Returns a
37 $cref/parameter/glossary/Parameter/$$ $icode y$$
38 with the same value as the
39 $cref/variable/glossary/Variable/$$ $icode x$$.
40 
41 $head x$$
42 The argument $icode x$$ has prototype
43 $codei%
44  const AD<%Base%> &x
45 %$$
46 The argument $icode x$$ may be a variable or parameter.
47 
48 
49 $head y$$
50 The result $icode y$$ has prototype
51 $codei%
52  AD<%Base%> &y
53 %$$
54 The return value $icode y$$ will be a parameter.
55 
56 
57 $head Example$$
58 $children%
59  example/general/var2par.cpp
60 %$$
61 The file
62 $cref var2par.cpp$$
63 contains an example and test of this operation.
64 It returns true if it succeeds and false otherwise.
65 
66 $end
67 ------------------------------------------------------------------------------
68 */
69 
70 // BEGIN CppAD namespace
71 namespace CppAD {
72 
73 template <class Base>
76 { AD<Base> y(x.value_);
77  return y;
78 }
79 
80 
81 template <class Base>
84 { AD<Base> y(x.ADBase());
85  y.id_ = 0;
86 }
87 
88 
89 } // END CppAD namespace
90 
91 # endif
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION AD< Base > Var2Par(const AD< Base > &x)
Definition: var2par.hpp:75
Base value_
Definition: ad.hpp:38
Definition: ad.hpp:34
#define CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
A version of the inline command that works with MC compiler.
Definition: define.hpp:43
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
Class used to hold a reference to an element of a VecAD object.
Definition: vec_ad.hpp:352