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

Go to the documentation of this file.
00001 # ifndef CPPAD_MUL_INCLUDED
00002 # define CPPAD_MUL_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 //  BEGIN CppAD namespace
00016 namespace CppAD {
00017 
00018 template <class Base>
00019 AD<Base> AD<Base>::operator *(const AD<Base> &right) const
00020 {
00021         AD<Base> result;
00022         CPPAD_ASSERT_UNKNOWN( Parameter(result) );
00023 
00024         result.value_  = value_ * right.value_;
00025 
00026         if( Variable(*this) )
00027         {       if( Variable(right) )
00028                 {       // result = variable * variable
00029                         CPPAD_ASSERT_KNOWN(
00030                                 id_ == right.id_,
00031                                 "Multiplying AD objects that are"
00032                                 " variables on different tapes."
00033                         );
00034                         tape_this()->RecordOp(
00035                                 MulvvOp, 
00036                                 result, 
00037                                 taddr_, 
00038                                 right.taddr_
00039                         );
00040                 }
00041                 else if( IdenticalZero(right.value_) )
00042                 {       // result = variable * 0
00043                 }
00044                 else if( IdenticalOne(right.value_) )
00045                 {       // result = variable * 1
00046                         result.make_variable(id_, taddr_);
00047                 }
00048                 else
00049                 {       // result = variable * parameter
00050                         tape_this()->RecordOp(
00051                                 MulvpOp, 
00052                                 result, 
00053                                 taddr_, 
00054                                 right.value_
00055                         );
00056                 }
00057         }
00058         else if( Variable(right) )
00059         {       if( IdenticalZero(value_)  )
00060                 {       // result = 0 * variable
00061                 }
00062                 else if( IdenticalOne(value_) )
00063                 {       // result = 1 * variable
00064                         result.make_variable(right.id_, right.taddr_);
00065                 }
00066                 else
00067                 {       // result = parameter * variable
00068                         right.tape_this()->RecordOp(
00069                                 MulpvOp, 
00070                                 result, 
00071                                 value_, 
00072                                 right.taddr_
00073                         );
00074                 }
00075         }
00076 
00077         return result;
00078 }
00079 
00080 // convert other cases to the case above
00081 CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(*)
00082 
00083 
00084 } // END CppAD namespace
00085 
00086 # endif 

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