CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
parameter_op.hpp
Go to the documentation of this file.
1 // $Id: parameter_op.hpp 3845 2016-11-19 01:50:47Z bradbell $
2 # ifndef CPPAD_LOCAL_PARAMETER_OP_HPP
3 # define CPPAD_LOCAL_PARAMETER_OP_HPP
4 
5 /* --------------------------------------------------------------------------
6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
7 
8 CppAD is distributed under multiple licenses. This distribution is under
9 the terms of the
10  Eclipse Public License Version 1.0.
11 
12 A copy of this license is included in the COPYING file of this distribution.
13 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
14 -------------------------------------------------------------------------- */
15 
16 
17 namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE
18 /*!
19 \file parameter_op.hpp
20 Zero order forward mode for ParOp
21 */
22 
23 
24 /*!
25 Compute zero order forward mode Taylor coefficient for result of op = ParOp.
26 
27 The C++ source code corresponding to this operation is one of the following
28 \verbatim
29  ADFun<Base> f(x, y)
30  f.Dependent(x, y)
31 \endverbatim
32 where some of the components of the vector y are parameters.
33 
34 \tparam Base
35 base type for the operator; i.e., this operation was recorded
36 using AD< \a Base > and computations by this routine are done using type
37 \a Base .
38 
39 \param i_z
40 variable index corresponding to the result for this operation;
41 i.e. the row index in \a taylor corresponding to the component of y
42 that is a parameter.
43 
44 \param arg
45 \a arg[0]
46 \n
47 index corresponding to the parameter value for this operator.
48 
49 \param num_par
50 is the number of parameters in \a parameter.
51 
52 \param parameter
53 \b Input: \a parameter[ \a arg[0] ] is the value of a component
54 of y that is a parameter.
55 
56 \param cap_order
57 number of colums in the matrix containing all the Taylor coefficients.
58 
59 \param taylor
60 \b Output: \a taylor [ \a i_z * \a cap_order + 0 ]
61 is the zero order Taylor coefficient corresponding to z.
62 
63 \par Checked Assertions where op is the unary operator with one result:
64 \li NumArg(op) == 1
65 \li NumRes(op) == 1
66 \li \a size_t(arg[0]) < num_par
67 \li \a 0 < \a cap_order
68 */
69 template <class Base>
70 inline void forward_par_op_0(
71  size_t i_z ,
72  const addr_t* arg ,
73  size_t num_par ,
74  const Base* parameter ,
75  size_t cap_order ,
76  Base* taylor )
77 {
78  // check assumptions
81  CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par );
82  CPPAD_ASSERT_UNKNOWN( 0 < cap_order );
83 
84  Base* z = taylor + i_z * cap_order;
85 
86  z[0] = parameter[ arg[0] ];
87 }
88 
89 } } // END_CPPAD_LOCAL_NAMESPACE
90 # endif
CPPAD_TAPE_ADDR_TYPE addr_t
Definition: declare_ad.hpp:44
size_t NumArg(OpCode op)
Number of arguments for a specified operator.
Definition: op_code.hpp:175
size_t NumRes(OpCode op)
Number of variables resulting from the specified operation.
Definition: op_code.hpp:281
void forward_par_op_0(size_t i_z, const addr_t *arg, size_t num_par, const Base *parameter, size_t cap_order, Base *taylor)
Compute zero order forward mode Taylor coefficient for result of op = ParOp.
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.