CppAD: A C++ Algorithmic Differentiation Package
20130102
|
00001 /* $Id$ */ 00002 # ifndef CPPAD_PARAMETER_OP_INCLUDED 00003 # define CPPAD_PARAMETER_OP_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 CPPAD_BEGIN_NAMESPACE 00018 /*! 00019 \defgroup parameter_op_hpp parameter_op.hpp 00020 \{ 00021 \file parameter_op.hpp 00022 Zero order forward mode for ParOp 00023 */ 00024 00025 00026 /*! 00027 Compute zero order forward mode Taylor coefficient for result of op = ParOp. 00028 00029 The C++ source code corresponding to this operation is one of the following 00030 \verbatim 00031 ADFun<Base> f(x, y) 00032 f.Dependent(x, y) 00033 \endverbatim 00034 where some of the components of the vector y are parameters. 00035 00036 \tparam Base 00037 base type for the operator; i.e., this operation was recorded 00038 using AD< \a Base > and computations by this routine are done using type 00039 \a Base . 00040 00041 \param i_z 00042 variable index corresponding to the result for this operation; 00043 i.e. the row index in \a taylor corresponding to the component of y 00044 that is a parameter. 00045 00046 \param arg 00047 \a arg[0] 00048 \n 00049 index corresponding to the parameter value for this operator. 00050 00051 \param num_par 00052 is the number of parameters in \a parameter. 00053 00054 \param parameter 00055 \b Input: \a parameter[ \a arg[0] ] is the value of a component 00056 of y that is a parameter. 00057 00058 \param nc_taylor 00059 number of colums in the matrix containing all the Taylor coefficients. 00060 00061 \param taylor 00062 \b Output: \a taylor [ \a i_z * \a nc_taylor + 0 ] 00063 is the zero order Taylor coefficient corresponding to z. 00064 00065 \par Checked Assertions where op is the unary operator with one result: 00066 \li NumArg(op) == 1 00067 \li NumRes(op) == 1 00068 \li \a size_t(arg[0]) < num_par 00069 \li \a 0 < \a nc_taylor 00070 */ 00071 template <class Base> 00072 inline void forward_par_op_0( 00073 size_t i_z , 00074 const addr_t* arg , 00075 size_t num_par , 00076 const Base* parameter , 00077 size_t nc_taylor , 00078 Base* taylor ) 00079 { 00080 // check assumptions 00081 CPPAD_ASSERT_UNKNOWN( NumArg(ParOp) == 1 ); 00082 CPPAD_ASSERT_UNKNOWN( NumRes(ParOp) == 1 ); 00083 CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); 00084 CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor ); 00085 00086 Base* z = taylor + i_z * nc_taylor; 00087 00088 z[0] = parameter[ arg[0] ]; 00089 } 00090 00091 /*! \} */ 00092 CPPAD_END_NAMESPACE 00093 # endif