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