CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
value.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_CORE_VALUE_HPP
2 # define CPPAD_CORE_VALUE_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 $begin Value$$
17 $spell
18  const
19 $$
20 
21 
22 
23 $section Convert From an AD Type to its Base Type$$
24 $mindex Value$$
25 
26 $head Syntax$$
27 $icode%b% = Value(%x%)%$$
28 
29 $head See Also$$
30 $cref var2par$$
31 
32 
33 $head Purpose$$
34 Converts from an AD type to the corresponding
35 $cref/base type/glossary/Base Type/$$.
36 
37 $head x$$
38 The argument $icode x$$ has prototype
39 $codei%
40  const AD<%Base%> &%x%
41 %$$
42 
43 $head b$$
44 The return value $icode b$$ has prototype
45 $codei%
46  %Base% %b%
47 %$$
48 
49 $head Operation Sequence$$
50 The result of this operation is not an
51 $cref/AD of Base/glossary/AD of Base/$$ object.
52 Thus it will not be recorded as part of an
53 AD of $icode Base$$
54 $cref/operation sequence/glossary/Operation/Sequence/$$.
55 
56 $head Restriction$$
57 If the argument $icode x$$ is a
58 $cref/variable/glossary/Variable/$$ its dependency information
59 would not be included in the $code Value$$ result (see above).
60 For this reason,
61 the argument $icode x$$ must be a $cref/parameter/glossary/Parameter/$$; i.e.,
62 it cannot depend on the current
63 $cref/independent variables/glossary/Tape/Independent Variable/$$.
64 
65 $head Example$$
66 $children%
67  example/general/value.cpp
68 %$$
69 The file
70 $cref value.cpp$$
71 contains an example and test of this operation.
72 
73 $end
74 -------------------------------------------------------------------------------
75 */
76 
77 // BEGIN CppAD namespace
78 namespace CppAD {
79 
80 template <class Base>
82 Base Value(const AD<Base> &x)
83 { Base result;
84 
86  Parameter(x) ,
87  "Value: argument is a variable (not a parameter)"
88  );
89 
90 
91  result = x.value_;
92 
93  return result;
94 }
95 
96 }
97 // END CppAD namespace
98 
99 
100 # endif
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
Base value_
Definition: ad.hpp:38
Definition: ad.hpp:34
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION Base Value(const AD< Base > &x)
Definition: value.hpp:82
#define CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
A version of the inline command that works with MC compiler.
Definition: define.hpp:43
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Parameter(const AD< Base > &x)
Definition: par_var.hpp:80