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