CppAD: A C++ Algorithmic Differentiation Package  20171217
identical.hpp
Go to the documentation of this file.
1 // $Id$
4
5 /* --------------------------------------------------------------------------
7
9 the terms of the
10  Eclipse Public License Version 1.0.
11
12 A copy of this license is included in the COPYING file of this distribution.
14 -------------------------------------------------------------------------- */
15
17
19 /*!
20 \file identical.hpp
21 Check if certain properties is true for any possible AD tape play back.
22 */
23
24 // ---------------------------------------------------------------------------
25 /*!
26 Determine if an AD<Base> object is a parameter, and could never have
27 a different value during any tape playback.
28
29 An AD<Base> object \c x is identically a parameter if and only if
30 all of the objects in the following chain are parameters:
31 \code
32  x , x.value , x.value.value , ...
33 \endcode
34 In such a case, the value of the object will always be the same
35 no matter what the independent variable values are at any level.
36
37 \param x
38 values that we are checking for identically a pamameter.
39
40 \return
41 returns true iff \c x is identically a parameter.
42 */
43 template <class Base>
46 { return Parameter(x) && IdenticalPar(x.value_); }
47 // Zero ==============================================================
48 /*!
49 Determine if an AD<Base> is equal to zero,
50 and must be equal zero during any tape playback.
51
52 \param x
53 object that we are checking.
54
55 \return
56 returns true if and only if
57 \c x is equals zero and is identically a parameter \ref CppAD::IdenticalPar.
58 */
59 template <class Base>
62 { return Parameter(x) && IdenticalZero(x.value_); }
63 // One ==============================================================
64 /*!
65 Determine if an AD<Base> is equal to one,
66 and must be equal one during any tape playback.
67
68 \param x
69 object that we are checking.
70
71 \return
72 returns true if and only if
73 \c x is equals one and is identically a parameter \ref CppAD::IdenticalPar.
74 */
75 template <class Base>
78 { return Parameter(x) && IdenticalOne(x.value_); }
79 // Equal ===================================================================
80 /*!
81 Determine if two AD<Base> objects are equal,
82 and must be equal during any tape playback.
83
84 \param x
85 first of two objects we are checking for equal.
86
87 \param y
88 second of two objects we are checking for equal.
89
90 \return
91 returns true if and only if
92 the arguments are equal and both identically parameters \ref CppAD::IdenticalPar.
93 */
94 template <class Base>
98 { bool parameter;
99  parameter = ( Parameter(x) & Parameter(y) );
100  return parameter && IdenticalEqualPar(x.value_, y.value_);
101 }
102 // ==========================================================================
103
105 # endif
Define processor symbols and macros that are used by CppAD.
Base value_