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
compound_assign.hpp
Go to the documentation of this file.
1
# ifndef CPPAD_CORE_COMPOUND_ASSIGN_HPP
2
# define CPPAD_CORE_COMPOUND_ASSIGN_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 compound_assign$$
18
$spell
19
Op
20
VecAD
21
const
22
$$
23
24
$section AD Compound Assignment Operators$$
25
$mindex + add plus - subtract minus * multiply times / divide multiple$$
26
27
28
29
30
31
32
$head Syntax$$
33
$icode%x% %Op% %y%$$
34
35
$head Purpose$$
36
Performs compound assignment operations
37
where either $icode x$$ has type
38
$codei%AD<%Base%>%$$.
39
40
$head Op$$
41
The operator $icode Op$$ is one of the following
42
$table
43
$bold Op$$ $cnext $bold Meaning$$ $rnext
44
$code +=$$ $cnext $icode x$$ is assigned $icode x$$ plus $icode y$$ $rnext
45
$code -=$$ $cnext $icode x$$ is assigned $icode x$$ minus $icode y$$ $rnext
46
$code *=$$ $cnext $icode x$$ is assigned $icode x$$ times $icode y$$ $rnext
47
$code /=$$ $cnext $icode x$$ is assigned $icode x$$ divided by $icode y$$
48
$tend
49
50
$head Base$$
51
The type $icode Base$$ is determined by the operand $icode x$$.
52
53
$head x$$
54
The operand $icode x$$ has the following prototype
55
$codei%
56
AD<%Base%> &%x%
57
%$$
58
59
$head y$$
60
The operand $icode y$$ has the following prototype
61
$codei%
62
const %Type% &%y%
63
%$$
64
where $icode Type$$ is
65
$codei%VecAD<%Base%>::reference%$$,
66
$codei%AD<%Base%>%$$,
67
$icode Base$$, or
68
$code double$$.
69
70
$head Result$$
71
The result of this assignment
72
can be used as a reference to $icode x$$.
73
For example, if $icode z$$ has the following type
74
$codei%
75
AD<%Base%> %z%
76
%$$
77
then the syntax
78
$codei%
79
%z% = %x% += %y%
80
%$$
81
will compute $icode x$$ plus $icode y$$
82
and then assign this value to both $icode x$$ and $icode z$$.
83
84
85
$head Operation Sequence$$
86
This is an $cref/atomic/glossary/Operation/Atomic/$$
87
$cref/AD of Base/glossary/AD of Base/$$ operation
88
and hence it is part of the current
89
AD of $icode Base$$
90
$cref/operation sequence/glossary/Operation/Sequence/$$.
91
92
$children%
93
example/general/add_eq.cpp%
94
example/general/sub_eq.cpp%
95
example/general/mul_eq.cpp%
96
example/general/div_eq.cpp
97
%$$
98
99
$head Example$$
100
The following files contain examples and tests of these functions.
101
Each test returns true if it succeeds and false otherwise.
102
$table
103
$rref AddEq.cpp$$
104
$rref sub_eq.cpp$$
105
$rref mul_eq.cpp$$
106
$rref div_eq.cpp$$
107
$tend
108
109
$head Derivative$$
110
If $latex f$$ and $latex g$$ are
111
$cref/Base functions/glossary/Base Function/$$
112
113
$subhead Addition$$
114
$latex \[
115
\D{[ f(x) + g(x) ]}{x} = \D{f(x)}{x} + \D{g(x)}{x}
116
\] $$
117
118
$subhead Subtraction$$
119
$latex \[
120
\D{[ f(x) - g(x) ]}{x} = \D{f(x)}{x} - \D{g(x)}{x}
121
\] $$
122
123
$subhead Multiplication$$
124
$latex \[
125
\D{[ f(x) * g(x) ]}{x} = g(x) * \D{f(x)}{x} + f(x) * \D{g(x)}{x}
126
\] $$
127
128
$subhead Division$$
129
$latex \[
130
\D{[ f(x) / g(x) ]}{x} =
131
[1/g(x)] * \D{f(x)}{x} - [f(x)/g(x)^2] * \D{g(x)}{x}
132
\] $$
133
134
$end
135
-----------------------------------------------------------------------------
136
*/
137
# include <
cppad/core/add_eq.hpp
>
138
# include <
cppad/core/sub_eq.hpp
>
139
# include <
cppad/core/mul_eq.hpp
>
140
# include <
cppad/core/div_eq.hpp
>
141
142
# endif
sub_eq.hpp
div_eq.hpp
add_eq.hpp
mul_eq.hpp
cppad
core
compound_assign.hpp
Generated by
1.8.5