00001 # ifndef CPPAD_ADD_EQ_INCLUDED
00002 # define CPPAD_ADD_EQ_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 namespace CppAD {
00017
00018 template <class Base>
00019 AD<Base>& AD<Base>::operator += (const AD<Base> &right)
00020 { Base left;
00021
00022 left = value_;
00023 value_ += right.value_;
00024
00025 if( Parameter(*this) )
00026 { if( Variable(right) )
00027 { if( IdenticalZero(left) )
00028 {
00029 make_variable(right.id_, right.taddr_);
00030 }
00031 else right.tape_this()->RecordOp(AddpvOp,
00032 *this, left, right.taddr_
00033 );
00034 }
00035 }
00036 else if( Parameter(right) )
00037 { if( ! IdenticalZero( right.value_ ) )
00038 { tape_this()->RecordOp(AddvpOp,
00039 *this, taddr_, right.value_
00040 );
00041 }
00042 }
00043 else
00044 { CPPAD_ASSERT_KNOWN(
00045 id_ == right.id_,
00046 "Adding AD objects that are"
00047 " variables on different tapes."
00048 );
00049 tape_this()->RecordOp(AddvvOp,
00050 *this, taddr_, right.taddr_
00051 );
00052 }
00053 return *this;
00054 }
00055
00056 CPPAD_FOLD_ASSIGNMENT_OPERATOR(+=)
00057
00058 }
00059
00060 # endif