CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
identical.hpp
Go to the documentation of this file.
1 // $Id$
2 # ifndef CPPAD_CORE_IDENTICAL_HPP
3 # define CPPAD_CORE_IDENTICAL_HPP
4 
5 /* --------------------------------------------------------------------------
6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
7 
8 CppAD is distributed under multiple licenses. This distribution is under
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.
13 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
14 -------------------------------------------------------------------------- */
15 
16 # include <cppad/core/define.hpp>
17 
18 namespace CppAD { // BEGIN_CPPAD_NAMESPACE
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>
45 bool IdenticalPar(const AD<Base> &x)
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>
61 bool IdenticalZero(const AD<Base> &x)
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>
77 bool IdenticalOne(const AD<Base> &x)
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>
97 (const AD<Base> &x, const AD<Base> &y)
98 { bool parameter;
99  parameter = ( Parameter(x) & Parameter(y) );
100  return parameter && IdenticalEqualPar(x.value_, y.value_);
101 }
102 // ==========================================================================
103 
104 } // END_CPPAD_NAMESPACE
105 # endif
Define processor symbols and macros that are used by CppAD.
Base value_
Definition: ad.hpp:38
Definition: ad.hpp:34
bool IdenticalPar(const std::complex< double > &x)
#define CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
A version of the inline command that works with MC compiler.
Definition: define.hpp:43
bool IdenticalZero(const std::complex< double > &x)
bool IdenticalEqualPar(const std::complex< double > &x, const std::complex< double > &y)
bool IdenticalOne(const std::complex< double > &x)
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Parameter(const AD< Base > &x)
Definition: par_var.hpp:80