/home/coin/SVN-release/CoinAll-1.1.0/cppad/cppad/local/define.hpp

Go to the documentation of this file.
00001 # ifndef CPPAD_DEFINE_INCLUDED
00002 # define CPPAD_DEFINE_INCLUDED
00003 
00004 /* --------------------------------------------------------------------------
00005 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell
00006 
00007 CppAD is distributed under multiple licenses. This distribution is under
00008 the terms of the 
00009                     Common Public License Version 1.0.
00010 
00011 A copy of this license is included in the COPYING file of this distribution.
00012 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
00013 -------------------------------------------------------------------------- */
00014 
00015 /*
00016 $begin Define$$ $comment CppAD Developer Documentation$$
00017 $spell
00018         bool
00019         cppad.hpp
00020         Microsoft
00021         VecAD_reference
00022         Cpp
00023         inline
00024         namespace
00025         std
00026         const
00027         Op
00028         OpenMp
00029 $$
00030 $aindex head$$
00031 
00032 $mindex macro definition$$
00033 $section Macros Used by CppAD Implementation$$ 
00034 
00035 $head CPPAD_NULL$$
00036 The preprocessor symbol $code CPPAD_NULL$$ is used for a null pointer. 
00037 If it is not yet defined,
00038 it is defined when $code cppad/local/define.hpp/$$ is included.
00039 
00040 $head CPPAD_MAX_NUM_THREADS$$
00041 The preprocessor symbol $code CPPAD_MAX_NUM_THREADS$$ 
00042 is the maximum number of OpenMp threads that can
00043 be used with CppAD.
00044 If it is not yet defined,
00045 it is defined when $code cppad/local/define.hpp/$$ is included.
00046 
00047 $head CPPAD_FOLD_ASSIGNMENT_OPERATOR$$
00048 The syntax
00049 $syntax%
00050         CPPAD_FOLD_ASSIGNMENT_OPERATOR(%Op%)
00051 %$$
00052 assumes that the operator
00053 $syntax%
00054         %left% %Op% %right%
00055 %$$
00056 is defined for the case where $italic left$$ and $italic right$$ 
00057 have type $syntax%AD<%Base%>%$$.
00058 It uses this case to define the cases where
00059 $italic left$$ has type $syntax%AD<%Base%>%$$ and
00060 $italic right$$ has type
00061 $syntax%VecAD_reference<%Base%>%$$,
00062 $syntax%AD<%Base%>%$$,
00063 $italic Base$$, or
00064 $code double$$.
00065 The argument $italic right$$ is $code const$$ and call by reference.
00066 This macro converts the operands to $syntax%AD<%Base%>%$$ and then
00067 uses the definition of the same operation for that case. 
00068 
00069 $head CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR$$
00070 The syntax
00071 $syntax%
00072         CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(%Op%)
00073 %$$
00074 assumes that the operator
00075 $syntax%
00076         %left% %Op% %right%
00077 %$$
00078 is defined for the case where $italic left$$ and $italic right$$ 
00079 and the result of the operation all 
00080 have type $syntax%AD<%Base%>%$$.
00081 It uses this case to define the cases either $italic left$$
00082 or $italic right$$ has type
00083 $syntax%VecAD_reference<%Base%>%$$ or
00084 $syntax%AD<%Base%>%$$
00085 and the type of the other operand is one of the following:
00086 $syntax%VecAD_reference<%Base%>%$$,
00087 $syntax%AD<%Base%>%$$,
00088 $italic Base$$,
00089 $code double$$.
00090 All of the arguments are $code const$$ and call by reference.
00091 This macro converts the operands to $syntax%AD<%Base%>%$$ and then
00092 uses the definition of the same operation for that case. 
00093 
00094 $head CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR$$
00095 The syntax
00096 $syntax%
00097         CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(%Op%)
00098 %$$
00099 assumes that the operator
00100 $syntax%
00101         %left% %Op% %right%
00102 %$$
00103 is defined for the case where $italic left$$ and $italic right$$ 
00104 have type $syntax%AD<%Base%>%$$
00105 and the result has type $code bool$$.
00106 It uses this case to define the cases either $italic left$$
00107 or $italic right$$ has type
00108 $syntax%VecAD_reference<%Base%>%$$ or
00109 $syntax%AD<%Base%>%$$
00110 and the type of the other operand is one of the following:
00111 $syntax%VecAD_reference<%Base%>%$$,
00112 $syntax%AD<%Base%>%$$,
00113 $italic Base$$,
00114 $code double$$.
00115 All of the arguments are $code const$$ and call by reference.
00116 This macro converts the operands to $syntax%AD<%Base%>%$$ and then
00117 uses the definition of the same operation for that case. 
00118 
00119 
00120 $end
00121 */
00122 
00123 # ifndef CPPAD_NULL
00124 # define CPPAD_NULL     0
00125 # endif
00126 
00127 # ifndef CPPAD_MAX_NUM_THREADS
00128 # ifdef _OPENMP
00129 # define CPPAD_MAX_NUM_THREADS 32
00130 # else
00131 # define CPPAD_MAX_NUM_THREADS 1
00132 # endif
00133 # endif
00134 
00135 
00136 # define CPPAD_FOLD_ASSIGNMENT_OPERATOR(Op)                             \
00137                                                                         \
00138 template <class Base>                                                   \
00139 inline AD<Base>& operator Op                                            \
00140 (AD<Base> &left, double right)                                          \
00141 {       return left Op AD<Base>(right); }                               \
00142                                                                         \
00143 template <class Base>                                                   \
00144 inline AD<Base>& operator Op                                            \
00145 (AD<Base> &left, const Base &right)                                     \
00146 {       return left Op AD<Base>(right); }                               \
00147                                                                         \
00148 inline AD<double>& operator Op                                          \
00149 (AD<double> &left, const double &right)                                 \
00150 {       return left Op AD<double>(right); }                             \
00151                                                                         \
00152 template <class Base>                                                   \
00153 inline AD<Base>& operator Op                                            \
00154 (AD<Base> &left, const VecAD_reference<Base> &right)                    \
00155 {       return left Op right.ADBase(); }
00156 
00157 // =====================================================================
00158 
00159 # define CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(Op)                      \
00160 /* ----------------------------------------------------------------*/  \
00161 /* Operations with VecAD_reference<Base> and AD<Base> only*/           \
00162                                                                        \
00163 template <class Base>                                                  \
00164 inline AD<Base> operator Op                                            \
00165 (const AD<Base> &left, const VecAD_reference<Base> &right)             \
00166 {       return left Op right.ADBase(); }                               \
00167                                                                        \
00168 template <class Base>                                                  \
00169 inline AD<Base> operator Op                                            \
00170 (const VecAD_reference<Base> &left, const VecAD_reference<Base> &right)\
00171 {       return left.ADBase() Op right.ADBase(); }                      \
00172                                                                        \
00173 template <class Base>                                                  \
00174 inline AD<Base> operator Op                                            \
00175         (const VecAD_reference<Base> &left, const AD<Base> &right)     \
00176 {       return left.ADBase() Op right; }                               \
00177 /* ----------------------------------------------------------------*/  \
00178 /* Operations Base */                                                  \
00179                                                                        \
00180 template <class Base>                                                  \
00181 inline AD<Base> operator Op                                            \
00182         (const Base &left, const AD<Base> &right)                      \
00183 {       return AD<Base>(left) Op right; }                              \
00184                                                                        \
00185 template <class Base>                                                  \
00186 inline AD<Base> operator Op                                            \
00187         (const Base &left, const VecAD_reference<Base> &right)         \
00188 {       return AD<Base>(left) Op right.ADBase(); }                     \
00189                                                                        \
00190 template <class Base>                                                  \
00191 inline AD<Base> operator Op                                            \
00192         (const AD<Base> &left, const Base &right)                      \
00193 {       return left Op AD<Base>(right); }                              \
00194                                                                        \
00195 template <class Base>                                                  \
00196 inline AD<Base> operator Op                                            \
00197         (const VecAD_reference<Base> &left, const Base &right)         \
00198 {       return left.ADBase() Op AD<Base>(right); }                     \
00199                                                                        \
00200 /* ----------------------------------------------------------------*/  \
00201 /* Operations double */                                                \
00202                                                                        \
00203 template <class Base>                                                  \
00204 inline AD<Base> operator Op                                            \
00205         (const double &left, const AD<Base> &right)                    \
00206 {       return AD<Base>(left) Op right; }                              \
00207                                                                        \
00208 template <class Base>                                                  \
00209 inline AD<Base> operator Op                                            \
00210         (const double &left, const VecAD_reference<Base> &right)       \
00211 {       return AD<Base>(left) Op right.ADBase(); }                     \
00212                                                                        \
00213 template <class Base>                                                  \
00214 inline AD<Base> operator Op                                            \
00215         (const AD<Base> &left, const double &right)                    \
00216 {       return left Op AD<Base>(right); }                              \
00217                                                                        \
00218 template <class Base>                                                  \
00219 inline AD<Base> operator Op                                            \
00220         (const VecAD_reference<Base> &left, const double &right)       \
00221 {       return left.ADBase() Op AD<Base>(right); }                     \
00222 /* ----------------------------------------------------------------*/  \
00223 /* Special case to avoid ambuigity when Base is double */              \
00224                                                                        \
00225 inline AD<double> operator Op                                          \
00226         (const double &left, const AD<double> &right)                  \
00227 {       return AD<double>(left) Op right; }                            \
00228                                                                        \
00229 inline AD<double> operator Op                                          \
00230         (const double &left, const VecAD_reference<double> &right)     \
00231 {       return AD<double>(left) Op right.ADBase(); }                   \
00232                                                                        \
00233 inline AD<double> operator Op                                          \
00234         (const AD<double> &left, const double &right)                  \
00235 {       return left Op AD<double>(right); }                            \
00236                                                                        \
00237 inline AD<double> operator Op                                          \
00238         (const VecAD_reference<double> &left, const double &right)     \
00239 {       return left.ADBase() Op AD<double>(right); }
00240 
00241 // =======================================================================
00242 
00243 
00244 # define CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(Op)                    \
00245 /* ----------------------------------------------------------------*/  \
00246 /* Operations with VecAD_reference<Base> and AD<Base> only*/           \
00247                                                                        \
00248 template <class Base>                                                  \
00249 inline bool operator Op                                                \
00250 (const AD<Base> &left, const VecAD_reference<Base> &right)             \
00251 {       return left Op right.ADBase(); }                               \
00252                                                                        \
00253 template <class Base>                                                  \
00254 inline bool operator Op                                                \
00255 (const VecAD_reference<Base> &left, const VecAD_reference<Base> &right)\
00256 {       return left.ADBase() Op right.ADBase(); }                      \
00257                                                                        \
00258 template <class Base>                                                  \
00259 inline bool operator Op                                                \
00260         (const VecAD_reference<Base> &left, const AD<Base> &right)     \
00261 {       return left.ADBase() Op right; }                               \
00262 /* ----------------------------------------------------------------*/  \
00263 /* Operations Base */                                                  \
00264                                                                        \
00265 template <class Base>                                                  \
00266 inline bool operator Op                                                \
00267         (const Base &left, const AD<Base> &right)                      \
00268 {       return AD<Base>(left) Op right; }                              \
00269                                                                        \
00270 template <class Base>                                                  \
00271 inline bool operator Op                                                \
00272         (const Base &left, const VecAD_reference<Base> &right)         \
00273 {       return AD<Base>(left) Op right.ADBase(); }                     \
00274                                                                        \
00275 template <class Base>                                                  \
00276 inline bool operator Op                                                \
00277         (const AD<Base> &left, const Base &right)                      \
00278 {       return left Op AD<Base>(right); }                              \
00279                                                                        \
00280 template <class Base>                                                  \
00281 inline bool operator Op                                                \
00282         (const VecAD_reference<Base> &left, const Base &right)         \
00283 {       return left.ADBase() Op AD<Base>(right); }                     \
00284                                                                        \
00285 /* ----------------------------------------------------------------*/  \
00286 /* Operations double */                                                \
00287                                                                        \
00288 template <class Base>                                                  \
00289 inline bool operator Op                                                \
00290         (const double &left, const AD<Base> &right)                    \
00291 {       return AD<Base>(left) Op right; }                              \
00292                                                                        \
00293 template <class Base>                                                  \
00294 inline bool operator Op                                                \
00295         (const double &left, const VecAD_reference<Base> &right)       \
00296 {       return AD<Base>(left) Op right.ADBase(); }                     \
00297                                                                        \
00298 template <class Base>                                                  \
00299 inline bool operator Op                                                \
00300         (const AD<Base> &left, const double &right)                    \
00301 {       return left Op AD<Base>(right); }                              \
00302                                                                        \
00303 template <class Base>                                                  \
00304 inline bool operator Op                                                \
00305         (const VecAD_reference<Base> &left, const double &right)       \
00306 {       return left.ADBase() Op AD<Base>(right); }                     \
00307 /* ----------------------------------------------------------------*/  \
00308 /* Special case to avoid ambuigity when Base is double */              \
00309                                                                        \
00310 inline bool operator Op                                                \
00311         (const double &left, const AD<double> &right)                  \
00312 {       return AD<double>(left) Op right; }                            \
00313                                                                        \
00314 inline bool operator Op                                                \
00315         (const double &left, const VecAD_reference<double> &right)     \
00316 {       return AD<double>(left) Op right.ADBase(); }                   \
00317                                                                        \
00318 inline bool operator Op                                                \
00319         (const AD<double> &left, const double &right)                  \
00320 {       return left Op AD<double>(right); }                            \
00321                                                                        \
00322 inline bool operator Op                                                \
00323         (const VecAD_reference<double> &left, const double &right)     \
00324 {       return left.ADBase() Op AD<double>(right); }
00325 
00326 # endif

Generated on Sun Nov 14 14:06:33 2010 for Coin-All by  doxygen 1.4.7