CppAD: A C++ Algorithmic Differentiation Package 20110419
|
00001 /* $Id$ */ 00002 # ifndef CPPAD_PRINT_OP_INCLUDED 00003 # define CPPAD_PRINT_OP_INCLUDED 00004 00005 /* -------------------------------------------------------------------------- 00006 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 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 print_op.hpp 00020 Zero order forward mode print operation. 00021 */ 00022 00023 00024 /*! 00025 Print operation for parameters; i.e., op = PripOp. 00026 00027 The C++ source code corresponding to this operation is 00028 \verbatim 00029 PrintFor(text, y) 00030 f.Forward(0, x) 00031 \endverbatim 00032 where y is a parameter. 00033 The PrintFor call puts the print operation on the tape 00034 and the print occurs during the zero order forward mode computation. 00035 00036 \par std::cout 00037 the results are printed on the C++ standard output stream. 00038 00039 \tparam Base 00040 base type for the operator; i.e., this operation was recorded 00041 using AD< \a Base > and computations by this routine are done using type 00042 \a Base . 00043 00044 \param arg 00045 \a arg[0] 00046 \n 00047 index of the text that this operation will print. 00048 \n 00049 \n 00050 \a arg[1] 00051 \n 00052 index of the parameter that this operation will print. 00053 00054 \param num_text 00055 is the total number of text characters on the tape 00056 (only used for error checking). 00057 00058 \param text 00059 \b Input: \a text[ \a arg[0] ] is the first character of the text 00060 that will be printed. All the characters from there to (but not including) 00061 the first '\\0' are printed. 00062 00063 \param num_par 00064 is the total number of parameters on the tape 00065 (only used for error checking). 00066 00067 \param parameter 00068 \b Input: \a parameter[ \a arg[1] ] is the parameter value 00069 that will be printed after the text. 00070 00071 \par Checked Assertions: 00072 \li text != CPPAD_NULL 00073 \li parameter != CPPAD_NULL 00074 \li NumArg(PripOp) == 2 00075 \li NumRes(PripOp) == 0 00076 \li arg[0] < num_text 00077 \li arg[1] < num_par 00078 */ 00079 template <class Base> 00080 inline void forward_prip_0( 00081 const size_t* arg , 00082 size_t num_text , 00083 const char* text , 00084 size_t num_par , 00085 const Base* parameter ) 00086 { 00087 // check assumptions 00088 CPPAD_ASSERT_UNKNOWN( text != CPPAD_NULL ) 00089 CPPAD_ASSERT_UNKNOWN( parameter != CPPAD_NULL ) 00090 CPPAD_ASSERT_UNKNOWN( NumArg(PripOp) == 2 ); 00091 CPPAD_ASSERT_UNKNOWN( NumRes(PripOp) == 0 ); 00092 CPPAD_ASSERT_UNKNOWN( arg[0] < num_text ); 00093 CPPAD_ASSERT_UNKNOWN( arg[1] < num_par ); 00094 00095 std::cout << text + arg[0]; 00096 std::cout << parameter[ arg[1] ]; 00097 } 00098 00099 /*! 00100 Print operation for variables; i.e., op = PrivOp. 00101 00102 The C++ source code corresponding to this operation is 00103 \verbatim 00104 PrintFor(text, y) 00105 f.Forward(0, x) 00106 \endverbatim 00107 where y is a variable. 00108 The PrintFor call puts the print operation on the tape 00109 and the print occurs during the zero order forward mode computation. 00110 00111 \par std::cout 00112 the results are printed on the C++ standard output stream. 00113 00114 \tparam Base 00115 base type for the operator; i.e., this operation was recorded 00116 using AD< \a Base > and computations by this routine are done using type 00117 \a Base . 00118 00119 \param i_z 00120 is the index of the next variable on the tape 00121 (only used for error checking). 00122 00123 \param arg 00124 \a arg[0] 00125 \n 00126 index of the text that this operation will print. 00127 \n 00128 \n 00129 \a arg[1] 00130 \n 00131 index of the variable that this operation will print. 00132 00133 \param num_text 00134 is the total number of text characters on the tape 00135 (only used for error checking). 00136 00137 \param text 00138 \b Input: \a text[ \a arg[0] ] is the first character of the text 00139 that will be printed. All the characters from there to (but not including) 00140 the first '\\0' are printed. 00141 00142 \param nc_taylor 00143 number of colums in the matrix containing all the Taylor coefficients. 00144 00145 \param taylor 00146 \b Input: \a taylor [ \a arg[1] * \a nc_taylor + 0 ] 00147 is zero order taylor coefficient that will be printed. 00148 00149 \par Checked Assertions: 00150 \li text != CPPAD_NULL 00151 \li NumArg(PrivOp) == 2 00152 \li NumRes(PrivOp) == 0 00153 \li arg[0] < num_test 00154 \li arg[1] <= i_z 00155 */ 00156 template <class Base> 00157 inline void forward_priv_0( 00158 size_t i_z , 00159 const size_t* arg , 00160 size_t num_text , 00161 const char* text , 00162 size_t nc_taylor , 00163 const Base* taylor ) 00164 { 00165 // check assumptions 00166 CPPAD_ASSERT_UNKNOWN( text != CPPAD_NULL ) 00167 CPPAD_ASSERT_UNKNOWN( NumArg(PripOp) == 2 ); 00168 CPPAD_ASSERT_UNKNOWN( NumRes(PripOp) == 0 ); 00169 CPPAD_ASSERT_UNKNOWN( arg[0] < num_text ); 00170 CPPAD_ASSERT_UNKNOWN( arg[1] <= i_z ); 00171 00172 std::cout << text + arg[0]; 00173 std::cout << taylor[ arg[1] * nc_taylor + 0 ]; 00174 } 00175 00176 CPPAD_END_NAMESPACE 00177 # endif