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