CppAD: A C++ Algorithmic Differentiation Package 20110419
ordered.hpp
Go to the documentation of this file.
00001 /* $Id$ */
00002 # ifndef CPPAD_ORDERED_INCLUDED
00003 # define CPPAD_ORDERED_INCLUDED
00004 
00005 /* --------------------------------------------------------------------------
00006 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell
00007 
00008 CppAD is distributed under multiple licenses. This distribution is under
00009 the terms of the 
00010                     Common 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 /*!
00021 \file ordered.hpp
00022 Check and AD values ordering properties relative to zero.
00023 */
00024 
00025 // GreaterThanZero ============================================================
00026 /*!
00027 Check if a float is greater than zero, 
00028 used by <tt>GreaterThanZero(AD<float>)</tt>.
00029 
00030 \param x
00031 value we are checking.
00032 
00033 \return
00034 returns true iff the \c x is greater than zero.
00035 */
00036 inline bool GreaterThanZero(const float &x)
00037 {       return x > 0.; }
00038 // ---------------------------------------------------------------------------
00039 /*!
00040 Check if a double is greater than zero, 
00041 used by <tt>GreaterThanZero(AD<double>)</tt>.
00042 
00043 \param x
00044 value we are checking.
00045 
00046 \return
00047 returns true iff the \c x is greater than zero.
00048 */
00049 inline bool GreaterThanZero(const double &x)
00050 {       return x > 0.; }
00051 // ---------------------------------------------------------------------------
00052 /*!
00053 Check if an AD<Base> is greater than zero.
00054 
00055 \param x
00056 value we are checking.
00057 
00058 \return
00059 returns true iff the \c x is greater than zero.
00060 */
00061 template <class Base>
00062 CPPAD_INLINE bool GreaterThanZero(const AD<Base> &x)
00063 {       return GreaterThanZero(x.value_); }
00064 // GreaterThanOrZero =========================================================
00065 /*!
00066 Check if a float is greater than or equal zero, 
00067 used by <tt>GreaterThanOrZero(AD<float>)</tt>.
00068 
00069 \param x
00070 value we are checking.
00071 
00072 \return
00073 returns true iff the \c x is greater than or equal zero.
00074 */
00075 inline bool GreaterThanOrZero(const float &x)
00076 {       return x >= 0.; }
00077 // ---------------------------------------------------------------------------
00078 /*!
00079 Check if a double is greater than or equal zero, 
00080 used by <tt>GreaterThanOrZero(AD<double>)</tt>.
00081 
00082 \param x
00083 value we are checking.
00084 
00085 \return
00086 returns true iff the \c x is greater than or equal zero.
00087 */
00088 inline bool GreaterThanOrZero(const double &x)
00089 {       return x >= 0.; }
00090 // ---------------------------------------------------------------------------
00091 /*!
00092 Check if an AD<Base> is greater than or equal zero.
00093 
00094 \param x
00095 value we are checking.
00096 
00097 \return
00098 returns true iff the \c x is greater than or equal zero.
00099 */
00100 template <class Base>
00101 CPPAD_INLINE bool GreaterThanOrZero(const AD<Base> &x)
00102 {       return GreaterThanOrZero(x.value_); }
00103 // LessThanZero ============================================================
00104 /*!
00105 Check if a float is less than zero, 
00106 used by <tt>LessThanZero(AD<float>)</tt>.
00107 
00108 \param x
00109 value we are checking.
00110 
00111 \return
00112 returns true iff the \c x is less than zero.
00113 */
00114 inline bool LessThanZero(const float &x)
00115 {       return x < 0.; }
00116 // ---------------------------------------------------------------------------
00117 /*!
00118 Check if a double is less than zero, 
00119 used by <tt>LessThanZero(AD<double>)</tt>.
00120 
00121 \param x
00122 value we are checking.
00123 
00124 \return
00125 returns true iff the \c x is less than zero.
00126 */
00127 inline bool LessThanZero(const double &x)
00128 {       return x < 0.; }
00129 // ---------------------------------------------------------------------------
00130 /*!
00131 Check if an AD<Base> is less than zero.
00132 
00133 \param x
00134 value we are checking.
00135 
00136 \return
00137 returns true iff the \c x is less than zero.
00138 */
00139 template <class Base>
00140 CPPAD_INLINE bool LessThanZero(const AD<Base> &x)
00141 {       return LessThanZero(x.value_); }
00142 // LessThanOrZero =========================================================
00143 /*!
00144 Check if a float is less than or equal zero, 
00145 used by <tt>LessThanOrZero(AD<float>)</tt>.
00146 
00147 \param x
00148 value we are checking.
00149 
00150 \return
00151 returns true iff the \c x is less than or equal zero.
00152 */
00153 inline bool LessThanOrZero(const float &x)
00154 {       return x <= 0.; }
00155 // ---------------------------------------------------------------------------
00156 /*!
00157 Check if a double is less than or equal zero, 
00158 used by <tt>LessThanOrZero(AD<double>)</tt>.
00159 
00160 \param x
00161 value we are checking.
00162 
00163 \return
00164 returns true iff the \c x is less than or equal zero.
00165 */
00166 inline bool LessThanOrZero(const double &x)
00167 {       return x <= 0.; }
00168 // ---------------------------------------------------------------------------
00169 /*!
00170 Check if an AD<Base> is less than or equal zero.
00171 
00172 \param x
00173 value we are checking.
00174 
00175 \return
00176 returns true iff the \c x is less than or equal zero.
00177 */
00178 template <class Base>
00179 CPPAD_INLINE bool LessThanOrZero(const AD<Base> &x)
00180 {       return LessThanOrZero(x.value_); }
00181 // ============================================================================
00182 CPPAD_END_NAMESPACE
00183 # endif
00184