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

Go to the documentation of this file.
00001 # ifndef CPPAD_PAR_VAR_INCLUDED
00002 # define CPPAD_PAR_VAR_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 
00017 $begin ParVar$$
00018 $spell
00019         VecAD
00020         const
00021         bool
00022 $$
00023 
00024 $index Parameter$$
00025 $index Variable$$
00026 $section Is an AD Object a Parameter or Variable$$
00027 
00028 $head Syntax$$
00029 $syntax%%b% = Parameter(%x%)%$$
00030 $pre
00031 $$
00032 $syntax%%b% = Variable(%x%)%$$
00033 
00034 
00035 $head Purpose$$
00036 Determine if $italic x$$ is a 
00037 $xref/glossary/Parameter/parameter/$$ or 
00038 $xref/glossary/Variable/variable/$$. 
00039 
00040 $head x$$
00041 The argument $italic x$$ has prototype
00042 $syntax%
00043         const AD<%Base%>    &%x%
00044         const VecAD<%Base%> &%x%
00045 %$$
00046 
00047 $head b$$
00048 The return value $italic b$$ has prototype
00049 $syntax%
00050         bool %b%
00051 %$$
00052 The return value for $code Parameter$$ ($code Variable$$)
00053 is true if and only if $italic x$$ is a parameter (variable).
00054 Note that a $cref/VecAD<Base>/VecAD/$$ object
00055 is a variable if any element of the vector depends on the independent
00056 variables.
00057 
00058 $head Operation Sequence$$
00059 The result of this operation is not an
00060 $xref/glossary/AD of Base/AD of Base/$$ object.
00061 Thus it will not be recorded as part of an
00062 AD of $italic Base$$
00063 $xref/glossary/Operation/Sequence/operation sequence/1/$$.
00064 
00065 $head Example$$
00066 $children%
00067         example/par_var.cpp
00068 %$$
00069 The file
00070 $xref/ParVar.cpp/$$
00071 contains an example and test of these functions.
00072 It returns true if it succeeds and false otherwise.
00073 
00074 $end
00075 -----------------------------------------------------------------------------
00076 */
00077 
00078 namespace CppAD {
00079         // Parameter
00080         template <class Base>
00081         inline bool Parameter(const AD<Base> &x)
00082         {       size_t thread = x.id_ % CPPAD_MAX_NUM_THREADS;
00083                 return x.id_ != * AD<Base>::id_handle(thread); 
00084         }
00085 
00086         template <class Base>
00087         inline bool Parameter(const VecAD<Base> &x)
00088         {       size_t thread = x.id_ % CPPAD_MAX_NUM_THREADS;
00089                 return x.id_ != * AD<Base>::id_handle(thread); 
00090         }
00091 
00092         // Variable
00093         template <class Base>
00094         inline bool Variable(const AD<Base> &x)
00095         {       size_t thread = x.id_ % CPPAD_MAX_NUM_THREADS;
00096                 return x.id_ == * AD<Base>::id_handle(thread); 
00097         }
00098 
00099         template <class Base>
00100         inline bool Variable(const VecAD<Base> &x)
00101         {       size_t thread = x.id_ % CPPAD_MAX_NUM_THREADS;
00102                 return x.id_ == * AD<Base>::id_handle(thread); 
00103         }
00104 } 
00105 // END CppAD namespace
00106 
00107 
00108 # endif

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