CppAD: A C++ Algorithmic Differentiation Package
20130918
|
00001 /* $Id$ */ 00002 # ifndef CPPAD_VALUE_INCLUDED 00003 # define CPPAD_VALUE_INCLUDED 00004 00005 /* -------------------------------------------------------------------------- 00006 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell 00007 00008 CppAD is distributed under multiple licenses. This distribution is under 00009 the terms of the 00010 Eclipse Public License Version 1.0. 00011 00012 A copy of this license is included in the COPYING file of this distribution. 00013 Please visit http://www.coin-or.org/CppAD/ for information on other licenses. 00014 -------------------------------------------------------------------------- */ 00015 00016 /* 00017 $begin Value$$ 00018 $spell 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 $icode%b% = Value(%x%)%$$ 00032 00033 00034 $head Purpose$$ 00035 Converts from an AD type to the corresponding 00036 $cref/base type/glossary/Base Type/$$. 00037 00038 $head x$$ 00039 The argument $icode x$$ has prototype 00040 $codei% 00041 const AD<%Base%> &%x% 00042 %$$ 00043 00044 $head b$$ 00045 The return value $icode b$$ has prototype 00046 $codei% 00047 %Base% %b% 00048 %$$ 00049 00050 $head Operation Sequence$$ 00051 The result of this operation is not an 00052 $cref/AD of Base/glossary/AD of Base/$$ object. 00053 Thus it will not be recorded as part of an 00054 AD of $icode Base$$ 00055 $cref/operation sequence/glossary/Operation/Sequence/$$. 00056 00057 $head Restriction$$ 00058 If the argument $icode x$$ is a 00059 $cref/variable/glossary/Variable/$$ its dependency information 00060 would not be included in the $code Value$$ result (see above). 00061 For this reason, 00062 the argument $icode x$$ must be a $cref/parameter/glossary/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 $cref 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 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION 00083 Base Value(const AD<Base> &x) 00084 { Base result; 00085 00086 CPPAD_ASSERT_KNOWN( 00087 Parameter(x) , 00088 "Value: argument is a variable (not a parameter)" 00089 ); 00090 00091 00092 result = x.value_; 00093 00094 return result; 00095 } 00096 00097 } 00098 // END CppAD namespace 00099 00100 00101 # endif