00001 # ifndef CPPAD_VALUE_INCLUDED 00002 # define CPPAD_VALUE_INCLUDED 00003 00004 /* -------------------------------------------------------------------------- 00005 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell 00006 00007 CppAD is distributed under multiple licenses. This distribution is under 00008 the terms of the 00009 Common Public License Version 1.0. 00010 00011 A copy of this license is included in the COPYING file of this distribution. 00012 Please visit http://www.coin-or.org/CppAD/ for information on other licenses. 00013 -------------------------------------------------------------------------- */ 00014 00015 /* 00016 $begin Value$$ 00017 $spell 00018 inline 00019 const 00020 $$ 00021 00022 $index Value$$ 00023 00024 $index Base, from AD$$ 00025 $index AD, convert to Base$$ 00026 $index convert, AD to Base$$ 00027 00028 $section Convert From an AD Type to its Base Type$$ 00029 00030 $head Syntax$$ 00031 $syntax%%b% = Value(%x%)%$$ 00032 00033 00034 $head Purpose$$ 00035 Converts from an AD type to the corresponding 00036 $xref/glossary/Base Type/base type/$$. 00037 00038 $head x$$ 00039 The argument $italic x$$ has prototype 00040 $syntax% 00041 const AD<%Base%> &%x% 00042 %$$ 00043 00044 $head b$$ 00045 The return value $italic b$$ has prototype 00046 $syntax% 00047 %Base% %b% 00048 %$$ 00049 00050 $head Operation Sequence$$ 00051 The result of this operation is not an 00052 $xref/glossary/AD of Base/AD of Base/$$ object. 00053 Thus it will not be recorded as part of an 00054 AD of $italic Base$$ 00055 $xref/glossary/Operation/Sequence/operation sequence/1/$$. 00056 00057 $head Restriction$$ 00058 If the argument $italic x$$ is a 00059 $xref/glossary/Variable/variable/$$ its dependency information 00060 would not be included in the $code Value$$ result (see above). 00061 For this reason, 00062 the argument $italic x$$ must be a $xref/glossary/Parameter/parameter/$$; i.e., 00063 it cannot depend on the current 00064 $cref/independent variables/glossary/Tape/Independent Variable/$$. 00065 00066 $head Example$$ 00067 $children% 00068 example/value.cpp 00069 %$$ 00070 The file 00071 $xref/Value.cpp/$$ 00072 contains an example and test of this operation. 00073 00074 $end 00075 ------------------------------------------------------------------------------- 00076 */ 00077 00078 // BEGIN CppAD namespace 00079 namespace CppAD { 00080 00081 template <class Base> 00082 inline Base Value(const AD<Base> &x) 00083 { Base result; 00084 00085 CPPAD_ASSERT_KNOWN( 00086 Parameter(x) , 00087 "Value: argument is a variable (not a parameter)" 00088 ); 00089 00090 00091 result = x.value_; 00092 00093 return result; 00094 } 00095 00096 } 00097 // END CppAD namespace 00098 00099 00100 # endif