CppAD: A C++ Algorithmic Differentiation Package
20171217
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
ad_binary.hpp
Go to the documentation of this file.
1
# ifndef CPPAD_CORE_AD_BINARY_HPP
2
# define CPPAD_CORE_AD_BINARY_HPP
3
4
/* --------------------------------------------------------------------------
5
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
6
7
CppAD is distributed under multiple licenses. This distribution is under
8
the terms of the
9
Eclipse Public License Version 1.0.
10
11
A copy of this license is included in the COPYING file of this distribution.
12
Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
13
-------------------------------------------------------------------------- */
14
15
/*
16
-------------------------------------------------------------------------------
17
$begin ad_binary$$
18
$spell
19
Op
20
VecAD
21
const
22
$$
23
24
$section AD Binary Arithmetic Operators$$
25
$mindex + add plus - subtract minus * multiply times / divide$$
26
27
28
29
30
31
32
33
$head Syntax$$
34
$icode%z% = %x% %Op% %y%$$
35
36
$head Purpose$$
37
Performs arithmetic operations where either $icode x$$ or $icode y$$
38
has type
39
$codei%AD<%Base%>%$$ or
40
$cref%VecAD<Base>::reference%VecAD%VecAD<Base>::reference%$$.
41
42
$head Op$$
43
The operator $icode Op$$ is one of the following
44
$table
45
$bold Op$$ $cnext $bold Meaning$$ $rnext
46
$code +$$ $cnext $icode z$$ is $icode x$$ plus $icode y$$ $rnext
47
$code -$$ $cnext $icode z$$ is $icode x$$ minus $icode y$$ $rnext
48
$code *$$ $cnext $icode z$$ is $icode x$$ times $icode y$$ $rnext
49
$code /$$ $cnext $icode z$$ is $icode x$$ divided by $icode y$$
50
$tend
51
52
$head Base$$
53
The type $icode Base$$ is determined by the operand that
54
has type $codei%AD<%Base%>%$$ or $codei%VecAD<%Base%>::reference%$$.
55
56
$head x$$
57
The operand $icode x$$ has the following prototype
58
$codei%
59
const %Type% &%x%
60
%$$
61
where $icode Type$$ is
62
$codei%VecAD<%Base%>::reference%$$,
63
$codei%AD<%Base%>%$$,
64
$icode Base$$, or
65
$code double$$.
66
67
$head y$$
68
The operand $icode y$$ has the following prototype
69
$codei%
70
const %Type% &%y%
71
%$$
72
where $icode Type$$ is
73
$codei%VecAD<%Base%>::reference%$$,
74
$codei%AD<%Base%>%$$,
75
$icode Base$$, or
76
$code double$$.
77
78
79
$head z$$
80
The result $icode z$$ has the following prototype
81
$codei%
82
%Type% %z%
83
%$$
84
where $icode Type$$ is
85
$codei%AD<%Base%>%$$.
86
87
$head Operation Sequence$$
88
This is an $cref/atomic/glossary/Operation/Atomic/$$
89
$cref/AD of Base/glossary/AD of Base/$$ operation
90
and hence it is part of the current
91
AD of $icode Base$$
92
$cref/operation sequence/glossary/Operation/Sequence/$$.
93
94
$children%
95
example/general/add.cpp%
96
example/general/sub.cpp%
97
example/general/mul.cpp%
98
example/general/div.cpp
99
%$$
100
101
$head Example$$
102
The following files contain examples and tests of these functions.
103
Each test returns true if it succeeds and false otherwise.
104
$table
105
$rref add.cpp$$
106
$rref sub.cpp$$
107
$rref mul.cpp$$
108
$rref div.cpp$$
109
$tend
110
111
$head Derivative$$
112
If $latex f$$ and $latex g$$ are
113
$cref/Base functions/glossary/Base Function/$$
114
115
$subhead Addition$$
116
$latex \[
117
\D{[ f(x) + g(x) ]}{x} = \D{f(x)}{x} + \D{g(x)}{x}
118
\] $$
119
120
$subhead Subtraction$$
121
$latex \[
122
\D{[ f(x) - g(x) ]}{x} = \D{f(x)}{x} - \D{g(x)}{x}
123
\] $$
124
125
$subhead Multiplication$$
126
$latex \[
127
\D{[ f(x) * g(x) ]}{x} = g(x) * \D{f(x)}{x} + f(x) * \D{g(x)}{x}
128
\] $$
129
130
$subhead Division$$
131
$latex \[
132
\D{[ f(x) / g(x) ]}{x} =
133
[1/g(x)] * \D{f(x)}{x} - [f(x)/g(x)^2] * \D{g(x)}{x}
134
\] $$
135
136
$end
137
-----------------------------------------------------------------------------
138
*/
139
# include <
cppad/core/add.hpp
>
140
# include <
cppad/core/sub.hpp
>
141
# include <
cppad/core/mul.hpp
>
142
# include <
cppad/core/div.hpp
>
143
144
# endif
add.hpp
sub.hpp
div.hpp
mul.hpp
cppad
core
ad_binary.hpp
Generated by
1.8.5