CppAD: A C++ Algorithmic Differentiation Package 20110419
ad_binary.hpp
Go to the documentation of this file.
00001 /* $Id$ */
00002 # ifndef CPPAD_AD_BINARY_INCLUDED
00003 # define CPPAD_AD_BINARY_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 ad_binary$$
00019 $spell
00020         Op
00021         VecAD
00022         const
00023 $$
00024 
00025 $section AD Binary Arithmetic Operators$$
00026 
00027 $index binary, operator$$
00028 $index operator, binary$$
00029 
00030 $index +, binary operator$$
00031 $index add, binary operator$$
00032 $index plus, binary operator$$
00033 
00034 $index -, binary operator$$
00035 $index subtract, binary operator$$
00036 $index minus, binary operator$$
00037 
00038 $index *, binary operator$$
00039 $index multiply, binary operator$$
00040 $index times, binary operator$$
00041 
00042 $index /, binary operator$$
00043 $index divide, binary operator$$
00044 
00045 
00046 $head Syntax$$
00047 $syntax%%z% = %x% %Op% %y%$$
00048 
00049 $head Purpose$$
00050 Performs arithmetic operations where either $italic x$$ or $italic y$$
00051 has type 
00052 $syntax%AD<%Base%>%$$ or
00053 $cref%VecAD<Base>::reference%VecAD%VecAD<Base>::reference%$$. 
00054 
00055 $head Op$$
00056 The operator $italic Op$$ is one of the following
00057 $table
00058 $bold Op$$  $cnext $bold Meaning$$ $rnext
00059 $code +$$   $cnext $italic z$$ is $italic x$$ plus $italic y$$ $rnext
00060 $code -$$   $cnext $italic z$$ is $italic x$$ minus $italic y$$ $rnext
00061 $code *$$   $cnext $italic z$$ is $italic x$$ times $italic y$$ $rnext
00062 $code /$$   $cnext $italic z$$ is $italic x$$ divided by $italic y$$ 
00063 $tend
00064 
00065 $head Base$$
00066 The type $italic Base$$ is determined by the operand that
00067 has type $syntax%AD<%Base%>%$$ or $syntax%VecAD<%Base%>::reference%$$.
00068 
00069 $head x$$
00070 The operand $italic x$$ has the following prototype
00071 $syntax%
00072         const %Type% &%x%
00073 %$$
00074 where $italic Type$$ is
00075 $syntax%VecAD<%Base%>::reference%$$,
00076 $syntax%AD<%Base%>%$$,
00077 $italic Base$$, or
00078 $code double$$.
00079 
00080 $head y$$
00081 The operand $italic y$$ has the following prototype
00082 $syntax%
00083         const %Type% &%y%
00084 %$$
00085 where $italic Type$$ is
00086 $syntax%VecAD<%Base%>::reference%$$,
00087 $syntax%AD<%Base%>%$$,
00088 $italic Base$$, or
00089 $code double$$.
00090 
00091 
00092 $head z$$
00093 The result $italic z$$ has the following prototype
00094 $syntax%
00095         %Type% %z%
00096 %$$
00097 where $italic Type$$ is
00098 $syntax%AD<%Base%>%$$.
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.cpp%
00109         example/sub.cpp%
00110         example/mul.cpp%
00111         example/div.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 Add.cpp$$
00119 $rref Sub.cpp$$
00120 $rref Mul.cpp$$
00121 $rref Div.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.hpp>
00153 # include <cppad/local/sub.hpp>
00154 # include <cppad/local/mul.hpp>
00155 # include <cppad/local/div.hpp>
00156 
00157 # endif