00001 # ifndef CPPAD_COMPUTE_ASSIGN_INCLUDED 00002 # define CPPAD_COMPUTE_ASSIGN_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 ------------------------------------------------------------------------------- 00017 $begin compute_assign$$ 00018 $spell 00019 Op 00020 VecAD 00021 const 00022 $$ 00023 00024 $section AD Computed Assignment Operators$$ 00025 00026 $index assignment, operator$$ 00027 $index operator, assignment$$ 00028 00029 $index +, computed assignment$$ 00030 $index add, computed assignment$$ 00031 $index plus, computed assignment$$ 00032 00033 $index -, computed assignment$$ 00034 $index subtract, computed assignment$$ 00035 $index minus, computed assignment$$ 00036 00037 $index *, computed assignment$$ 00038 $index multiply, computed assignment$$ 00039 $index times, computed assignment$$ 00040 00041 $index /, computed assignment$$ 00042 $index divide, computed assignment$$ 00043 00044 $head Syntax$$ 00045 $syntax%%x% %Op% %y%$$ 00046 00047 $head Purpose$$ 00048 Performs computed assignment operations 00049 where either $italic x$$ has type 00050 $syntax%AD<%Base%>%$$. 00051 00052 $head Op$$ 00053 The operator $italic Op$$ is one of the following 00054 $table 00055 $bold Op$$ $cnext $bold Meaning$$ $rnext 00056 $code +=$$ $cnext $italic x$$ is assigned $italic x$$ plus $italic y$$ $rnext 00057 $code -=$$ $cnext $italic x$$ is assigned $italic x$$ minus $italic y$$ $rnext 00058 $code *=$$ $cnext $italic x$$ is assigned $italic x$$ times $italic y$$ $rnext 00059 $code /=$$ $cnext $italic x$$ is assigned $italic x$$ divided by $italic y$$ 00060 $tend 00061 00062 $head Base$$ 00063 The type $italic Base$$ is determined by the operand $italic x$$. 00064 00065 $head x$$ 00066 The operand $italic x$$ has the following prototype 00067 $syntax% 00068 AD<%Base%> &%x% 00069 %$$ 00070 00071 $head y$$ 00072 The operand $italic y$$ has the following prototype 00073 $syntax% 00074 const %Type% &%y% 00075 %$$ 00076 where $italic Type$$ is 00077 $syntax%VecAD<%Base%>::reference%$$, 00078 $syntax%AD<%Base%>%$$, 00079 $italic Base$$, or 00080 $code double$$. 00081 00082 $head Result$$ 00083 $index assignment, multiple$$ 00084 $index multiple, assignment$$ 00085 The result of this assignment 00086 can be used as a reference to $italic x$$. 00087 For example, if $italic z$$ has the following type 00088 $syntax% 00089 AD<%Base%> %z% 00090 %$$ 00091 then the syntax 00092 $syntax% 00093 %z% = %x% += %y% 00094 %$$ 00095 will compute $italic x$$ plus $italic y$$ 00096 and then assign this value to both $italic x$$ and $italic z$$. 00097 00098 00099 $head Operation Sequence$$ 00100 This is an $cref/atomic/glossary/Operation/Atomic/$$ 00101 $cref/AD of Base/glossary/AD of Base/$$ operation 00102 and hence it is part of the current 00103 AD of $italic Base$$ 00104 $cref/operation sequence/glossary/Operation/Sequence/$$. 00105 00106 $children% 00107 example/add_eq.cpp% 00108 example/sub_eq.cpp% 00109 example/mul_eq.cpp% 00110 example/div_eq.cpp 00111 %$$ 00112 00113 $head Example$$ 00114 The following files contain examples and tests of these functions. 00115 Each test returns true if it succeeds and false otherwise. 00116 $table 00117 $rref AddEq.cpp$$ 00118 $rref SubEq.cpp$$ 00119 $rref MulEq.cpp$$ 00120 $rref DivEq.cpp$$ 00121 $tend 00122 00123 $head Derivative$$ 00124 If $latex f$$ and $latex g$$ are 00125 $xref/glossary/Base Function/Base functions/$$ 00126 00127 $subhead Addition$$ 00128 $latex \[ 00129 \D{[ f(x) + g(x) ]}{x} = \D{f(x)}{x} + \D{g(x)}{x} 00130 \] $$ 00131 00132 $subhead Subtraction$$ 00133 $latex \[ 00134 \D{[ f(x) - g(x) ]}{x} = \D{f(x)}{x} - \D{g(x)}{x} 00135 \] $$ 00136 00137 $subhead Multiplication$$ 00138 $latex \[ 00139 \D{[ f(x) * g(x) ]}{x} = g(x) * \D{f(x)}{x} + f(x) * \D{g(x)}{x} 00140 \] $$ 00141 00142 $subhead Division$$ 00143 $latex \[ 00144 \D{[ f(x) / g(x) ]}{x} = 00145 [1/g(x)] * \D{f(x)}{x} - [f(x)/g(x)^2] * \D{g(x)}{x} 00146 \] $$ 00147 00148 $end 00149 ----------------------------------------------------------------------------- 00150 */ 00151 # include <cppad/local/add_eq.hpp> 00152 # include <cppad/local/sub_eq.hpp> 00153 # include <cppad/local/mul_eq.hpp> 00154 # include <cppad/local/div_eq.hpp> 00155 00156 # endif