CppAD: A C++ Algorithmic Differentiation Package  20130918
var2par.hpp
Go to the documentation of this file.
00001 /* $Id$ */
00002 # ifndef CPPAD_VAR2PAR_INCLUDED
00003 # define CPPAD_VAR2PAR_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 ------------------------------------------------------------------------------
00018 
00019 $begin Var2Par$$
00020 $spell
00021      var
00022      const
00023 $$
00024 
00025 $index Var2Par$$
00026 $index variable, convert to parameter$$
00027 $index parameter, convert from variable$$
00028 $index value_, obtain during taping$$
00029 
00030 $section Convert an AD Variable to a Parameter$$
00031 
00032 $head Syntax$$
00033 $icode%y% = Var2Par(%x%)%$$
00034 
00035 
00036 $head Purpose$$
00037 Returns a 
00038 $cref/parameter/glossary/Parameter/$$ $icode y$$
00039 with the same value as the 
00040 $cref/variable/glossary/Variable/$$ $icode x$$.
00041 
00042 $head x$$
00043 The argument $icode x$$ has prototype
00044 $codei%
00045      const AD<%Base%> &x
00046 %$$ 
00047 The argument $icode x$$ may be a variable or parameter.
00048 
00049 
00050 $head y$$
00051 The result $icode y$$ has prototype
00052 $codei%
00053      AD<%Base%> &y
00054 %$$ 
00055 The return value $icode y$$ will be a parameter. 
00056 
00057 
00058 $head Example$$
00059 $children%
00060      example/var2par.cpp
00061 %$$
00062 The file
00063 $cref var2par.cpp$$
00064 contains an example and test of this operation.
00065 It returns true if it succeeds and false otherwise.
00066 
00067 $end
00068 ------------------------------------------------------------------------------
00069 */
00070 
00071 //  BEGIN CppAD namespace
00072 namespace CppAD {
00073 
00074 template <class Base>
00075 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
00076 AD<Base> Var2Par(const AD<Base> &x)
00077 {    AD<Base> y(x.value_);
00078      return y;
00079 }
00080 
00081 
00082 template <class Base>
00083 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
00084 AD<Base> Var2Par(const VecAD_reference<Base> &x)
00085 {    AD<Base> y(x.ADBase()); 
00086      y.id_ = 0;
00087 }
00088 
00089 
00090 } // END CppAD namespace
00091 
00092 # endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines