CppAD: A C++ Algorithmic Differentiation Package
20130918
|
00001 /* $Id$ */ 00002 # ifndef CPPAD_IDENTICAL_INCLUDED 00003 # define CPPAD_IDENTICAL_INCLUDED 00004 00005 /* -------------------------------------------------------------------------- 00006 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell 00007 00008 CppAD is distributed under multiple licenses. This distribution is under 00009 the terms of the 00010 Eclipse 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 # include <cppad/local/define.hpp> 00017 00018 namespace CppAD { // BEGIN_CPPAD_NAMESPACE 00019 /*! 00020 \file identical.hpp 00021 Check if certain properties is true for any possible AD tape play back. 00022 */ 00023 00024 // --------------------------------------------------------------------------- 00025 /*! 00026 Determine if an AD<Base> object is a parameter, and could never have 00027 a different value during any tape playback. 00028 00029 An AD<Base> object \c x is identically a parameter if and only if 00030 all of the objects in the following chain are parameters: 00031 \code 00032 x , x.value , x.value.value , ... 00033 \endcode 00034 In such a case, the value of the object will always be the same 00035 no matter what the independent variable values are at any level. 00036 00037 \param x 00038 values that we are checking for identically a pamameter. 00039 00040 \return 00041 returns true iff \c x is identically a parameter. 00042 */ 00043 template <class Base> 00044 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION 00045 bool IdenticalPar(const AD<Base> &x) 00046 { return Parameter(x) && IdenticalPar(x.value_); } 00047 // Zero ============================================================== 00048 /*! 00049 Determine if an AD<Base> is equal to zero, 00050 and must be equal zero during any tape playback. 00051 00052 \param x 00053 object that we are checking. 00054 00055 \return 00056 returns true if and only if 00057 \c x is equals zero and is identically a parameter \ref IdenticalPar. 00058 */ 00059 template <class Base> 00060 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION 00061 bool IdenticalZero(const AD<Base> &x) 00062 { return Parameter(x) && IdenticalZero(x.value_); } 00063 // One ============================================================== 00064 /*! 00065 Determine if an AD<Base> is equal to one, 00066 and must be equal one during any tape playback. 00067 00068 \param x 00069 object that we are checking. 00070 00071 \return 00072 returns true if and only if 00073 \c x is equals one and is identically a parameter \ref IdenticalPar. 00074 */ 00075 template <class Base> 00076 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION 00077 bool IdenticalOne(const AD<Base> &x) 00078 { return Parameter(x) && IdenticalOne(x.value_); } 00079 // Equal =================================================================== 00080 /*! 00081 Determine if two AD<Base> objects are equal, 00082 and must be equal during any tape playback. 00083 00084 \param x 00085 first of two objects we are checking for equal. 00086 00087 \param y 00088 second of two objects we are checking for equal. 00089 00090 \return 00091 returns true if and only if 00092 the arguments are equal and both identically parameters \ref IdenticalPar. 00093 */ 00094 template <class Base> 00095 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION 00096 bool IdenticalEqualPar 00097 (const AD<Base> &x, const AD<Base> &y) 00098 { bool parameter; 00099 parameter = ( Parameter(x) & Parameter(y) ); 00100 return parameter && IdenticalEqualPar(x.value_, y.value_); 00101 } 00102 // ========================================================================== 00103 00104 } // END_CPPAD_NAMESPACE 00105 # endif