/home/coin/SVN-release/CoinAll-1.1.0/cppad/cppad/local/mul_op.hpp

Go to the documentation of this file.
00001 # ifndef CPPAD_MUL_OP_INCLUDED
00002 # define CPPAD_MUL_OP_INCLUDED
00003 
00004 /* --------------------------------------------------------------------------
00005 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell
00006 
00007 CppAD is distributed under multiple licenses. This distribution is under
00008 the terms of the 
00009                     Common Public License Version 1.0.
00010 
00011 A copy of this license is included in the COPYING file of this distribution.
00012 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
00013 -------------------------------------------------------------------------- */
00014 
00015 /*
00016 $begin ForMulvvOp$$ $comment CppAD Developer Documentation$$
00017 $spell
00018         Mul
00019         Mulpv
00020         Mulvp
00021         Mulvv
00022         Taylor
00023         const
00024         inline
00025         Op
00026 $$
00027 
00028 $index multiply, forward operator$$
00029 $index forward, multiply operator$$
00030 $index operator, multiply forward$$
00031 $index ForMul$$
00032 
00033 
00034 $section Forward Mode Multiplication Operator$$
00035 
00036 $head Syntax$$
00037 
00038 $syntax%inline void ForMulvvOp(size_t %d%,
00039         %Base% *%z%, const %Base% *%x%, const %Base% *%y%)%$$
00040 $pre
00041 $$
00042 $syntax%inline void ForMulpvOp(size_t %d%,
00043         %Base% *%z%, const %Base% *%p%, const %Base% *%v%)%$$
00044 $pre
00045 $$
00046 $syntax%inline void ForMulvpOp(size_t %d%,
00047         %Base% *%z%, const %Base% *%x%, const %Base% *%p%)%$$
00048 
00049 
00050 $head Description$$
00051 Computes the $italic d$$ order Taylor coefficient for $latex Z$$ where
00052 $table
00053 Operation  $cnext Value  $rnext
00054 Mulvv       $cnext $latex Z = X * Y$$ $rnext
00055 Mulpv       $cnext $latex Z = P * Y$$ $rnext
00056 Mulvp       $cnext $latex Z = X * P$$ 
00057 $tend
00058 
00059 $head x$$
00060 The vector $italic x$$ has length $latex d+1$$ and contains the
00061 $th d$$ order Taylor coefficient row vector for $italic X$$.
00062 
00063 $head y$$
00064 The vector $italic y$$ has length $latex d+1$$ and contains the
00065 $th d$$ order Taylor coefficient row vector for $italic Y$$.
00066 The vector $italic y$$ is not present in the MulL and MulR cases.
00067 
00068 $head p$$
00069 The scalar $syntax%*%p%$$ contains the value of the parameter $italic P$$.
00070 
00071 $head z$$
00072 The vector $italic z$$ has length $latex d+1$$.
00073 On input it contains the
00074 $th d-1$$ order Taylor coefficient row vector for $italic Z$$.
00075 On output it contains the
00076 $th d$$ order Taylor coefficient row vector for $italic Z$$; i.e.,
00077 $syntax%%z%[%d%]%$$ is set equal to the $th d$$ Taylor coefficient for
00078 the function $italic Z$$.
00079 
00080 $end
00081 ------------------------------------------------------------------------------
00082 $begin RevMulvvOp$$ $comment CppAD Developer Documentation$$
00083 $spell
00084         Mul
00085         Mulpv
00086         Mulvp
00087         Mulvv
00088         Taylor
00089         const
00090         inline
00091         Op
00092         px
00093         py
00094         pz
00095 $$
00096 
00097 
00098 $index multiply, reverse operator$$
00099 $index reverse, multiply operator$$
00100 $index operator, multiply reverse$$
00101 $index RevMul$$
00102 
00103 $section Reverse Mode Multiplication Operator$$
00104 
00105 $head Syntax$$
00106 
00107 $syntax%inline void RevMulvvOp(size_t %d%,
00108         const %Base% *%z%, const %Base% *%x%, const %Base% *%y%,
00109         const %Base% *%pz%, %Base% *%px%, %Base% *%py%)%$$
00110 $pre
00111 $$
00112 $syntax%inline void RevMulpvOp(size_t %d%,
00113         const %Base% *%z%, const %Base% *%p%, const %Base% *%y%,
00114         const %Base% *%pz%, %Base% *%py%)%$$
00115 $pre
00116 $$
00117 $syntax%inline void RevMulvpOp(size_t %d%,
00118         const %Base% *%z%, const %Base% *%x%, const %Base% *%p%,
00119         const %Base% *%pz%, %Base% *%px%)%$$
00120 
00121 $head Description$$
00122 We are given the partial derivatives for a function
00123 $latex G(z, x, y)$$ and we wish to compute the partial derivatives for
00124 the function
00125 $latex \[
00126         H(x, y) = G [ Z(x, y) , x , y ]
00127 \]$$
00128 where $latex Z(x, y)$$ is defined as the 
00129 $th d$$ order Taylor coefficient row vector for $italic Z$$ as
00130 a function of the corresponding vectors for 
00131 $italic X$$ and $italic Y$$ where
00132 
00133 $table
00134 Operation  $cnext Value  $rnext
00135 Mulvv       $cnext $latex Z = X * Y$$ $rnext
00136 Mulpv       $cnext $latex Z = P * Y$$ $rnext
00137 Mulvp       $cnext $latex Z = X * P$$ 
00138 $tend
00139 
00140 Note that $italic Z$$ has been used both the original multiplication 
00141 function and for the corresponding mapping of Taylor coefficients.
00142 
00143 $head z$$
00144 The vector $italic z$$ has length $latex d+1$$ and contains the
00145 $th d$$ order Taylor coefficient row vector for $italic Z$$.
00146 
00147 $head x$$
00148 The vector $italic x$$ has length $latex d+1$$ and contains the
00149 $th d$$ order Taylor coefficient row vector for $italic X$$.
00150 
00151 $head y$$
00152 The vector $italic y$$ has length $latex d+1$$ and contains the
00153 $th d$$ order Taylor coefficient row vector for $italic Y$$.
00154 
00155 $head p$$
00156 The scalar $syntax%*%p%$$ contains the value of the parameter $italic P$$.
00157 
00158 
00159 $head pz$$
00160 The vector $italic pz$$ has length $latex d+1$$ and 
00161 $syntax%%pz%[%j%]%$$ contains the partial for $italic G$$
00162 with respect to the $th j$$ order Taylor coefficient for $italic Z$$.
00163 
00164 $head On Input$$
00165 
00166 $subhead px$$
00167 The vector $italic px$$ has length $latex d+1$$ and 
00168 $syntax%%px%[%j%]%$$ contains the partial for $italic G$$
00169 with respect to the $th j$$ order Taylor coefficient for $italic X$$.
00170 
00171 $subhead py$$
00172 The vector $italic py$$ has length $latex d+1$$ and 
00173 $syntax%%py%[%j%]%$$ contains the partial for $italic G$$
00174 with respect to the $th j$$ order Taylor coefficient for $italic Y$$.
00175 
00176 $head On Output$$
00177 
00178 $subhead px$$
00179 If present,
00180 the vector $italic px$$ has length $latex d+1$$ and 
00181 $syntax%%px%[%j%]%$$ contains the partial for $italic H$$
00182 with respect to the $th j$$ order Taylor coefficient for $italic X$$.
00183 
00184 $subhead py$$
00185 If present,
00186 the vector $italic py$$ has length $latex d+1$$ and 
00187 $syntax%%py%[%j%]%$$ contains the partial for $italic H$$
00188 with respect to the $th j$$ order Taylor coefficient for $italic Y$$.
00189 
00190 $end
00191 ------------------------------------------------------------------------------
00192 */
00193 
00194 // BEGIN CppAD namespace
00195 namespace CppAD {
00196 
00197 // --------------------------- Mulvv -----------------------------------------
00198 
00199 template <class Base>
00200 inline void ForMulvvOp(size_t j, 
00201         Base *z, const Base *x, const Base *y)
00202 {
00203         size_t k;
00204 
00205         z[j] = Base(0);
00206         for(k = 0; k <= j; k++)
00207                 z[j] += x[j-k] * y[k];
00208 }
00209 
00210 template <class Base>
00211 inline void RevMulvvOp(size_t d, 
00212         const Base  *z, const Base *x, const Base *y,
00213         const Base *pz, Base      *px, Base      *py)
00214 {       size_t k;
00215 
00216         // number of indices to access
00217         size_t j = d + 1;
00218 
00219         while(j)
00220         {       --j;
00221                 for(k = 0; k <= j; k++)
00222                 {       
00223                         px[j-k] += pz[j] * y[k];
00224                         py[k]   += pz[j] * x[j-k];
00225                 }
00226         }
00227 }
00228 
00229 // --------------------------- Mulpv -----------------------------------------
00230 
00231 template <class Base>
00232 inline void ForMulpvOp(size_t j, 
00233         Base *z, const Base *p, const Base *y)
00234 {
00235         z[j] = (*p) * y[j];
00236 }
00237 
00238 template <class Base>
00239 inline void RevMulpvOp(size_t d, 
00240         const Base  *z, const Base *p, const Base *y,
00241         const Base *pz, Base *py)
00242 {
00243         // number of indices to access
00244         size_t j = d + 1;
00245 
00246         while(j)
00247         {       --j;
00248                 py[j] += pz[j] * (*p);
00249 
00250         }
00251 }
00252 
00253 // --------------------------- Mulvp -----------------------------------------
00254 
00255 template <class Base>
00256 inline void ForMulvpOp(size_t j,
00257         Base *z, const Base *x, const Base *p)
00258 {
00259         z[j] = x[j] * (*p);
00260 }
00261 
00262 template <class Base>
00263 inline void RevMulvpOp(size_t d,
00264         const Base  *z, const Base *x, const Base *p,
00265         const Base *pz, Base *px)
00266 {
00267         // number of indices to access
00268         size_t j = d + 1;
00269 
00270         while(j)
00271         {       --j;
00272                 px[j] += pz[j] * (*p);
00273         }
00274 }
00275 
00276 } // END CppAD namespace
00277 
00278 # endif

Generated on Sun Nov 14 14:06:33 2010 for Coin-All by  doxygen 1.4.7