本文整理汇总了C++中AD::tape_this方法的典型用法代码示例。如果您正苦于以下问题:C++ AD::tape_this方法的具体用法?C++ AD::tape_this怎么用?C++ AD::tape_this使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AD
的用法示例。
在下文中一共展示了AD::tape_this方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
CPPAD_INLINE bool operator != (const AD<Base> &left , const AD<Base> &right)
{ bool result = (left.value_ != right.value_);
ADTape<Base> *tape = CPPAD_NULL;
if( Variable(left) )
tape = left.tape_this();
else if ( Variable(right) )
tape = right.tape_this();
if( tape != CPPAD_NULL )
tape->RecordCompare(CompareNe, result, left, right);
return result;
}
示例2: if
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
bool operator >= (const AD<Base> &left , const AD<Base> &right)
{ bool result = (left.value_ >= right.value_);
bool var_left = Variable(left);
bool var_right = Variable(right);
ADTape<Base> *tape = CPPAD_NULL;
if( var_left )
{ tape = left.tape_this();
if( var_right )
{ if( result )
{ tape->Rec_.PutOp(LevvOp);
tape->Rec_.PutArg(right.taddr_, left.taddr_);
}
else
{ tape->Rec_.PutOp(LtvvOp);
tape->Rec_.PutArg(left.taddr_, right.taddr_);
}
}
else
{ addr_t arg1 = tape->Rec_.PutPar(right.value_);
if( result )
{ tape->Rec_.PutOp(LepvOp);
tape->Rec_.PutArg(arg1, left.taddr_);
}
else
{ tape->Rec_.PutOp(LtvpOp);
tape->Rec_.PutArg(left.taddr_, arg1);
}
}
}
else if ( var_right )
{ tape = right.tape_this();
addr_t arg0 = tape->Rec_.PutPar(left.value_);
if( result )
{ tape->Rec_.PutOp(LevpOp);
tape->Rec_.PutArg(right.taddr_, arg0);
}
else
{ tape->Rec_.PutOp(LtpvOp);
tape->Rec_.PutArg(arg0, right.taddr_);
}
}
return result;
}
示例3: Eval
// used during the recording process
AD<Base> Eval(const AD<Base> &x) const
{ AD<Base> z;
z.value_ = f(x.value_);
if( Variable(x) )
{ x.tape_this()->RecordDisOp(
z,
x.taddr_,
y_taddr
);
}
return z;
}
示例4: if
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
bool operator != (const AD<Base> &left , const AD<Base> &right)
{ bool result = (left.value_ != right.value_);
bool var_left = Variable(left);
bool var_right = Variable(right);
local::ADTape<Base> *tape = CPPAD_NULL;
if( var_left )
{ tape = left.tape_this();
if( var_right )
{ tape->Rec_.PutArg(left.taddr_, right.taddr_);
if( result )
tape->Rec_.PutOp(local::NevvOp);
else
tape->Rec_.PutOp(local::EqvvOp);
}
else
{ addr_t arg1 = tape->Rec_.PutPar(right.value_);
tape->Rec_.PutArg(arg1, left.taddr_);
if( result )
tape->Rec_.PutOp(local::NepvOp);
else
tape->Rec_.PutOp(local::EqpvOp);
}
}
else if ( var_right )
{ tape = right.tape_this();
addr_t arg0 = tape->Rec_.PutPar(left.value_);
tape->Rec_.PutArg(arg0, right.taddr_);
if( result )
tape->Rec_.PutOp(local::NepvOp);
else
tape->Rec_.PutOp(local::EqpvOp);
}
return result;
}
示例5: CondExpOp
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
AD<Base> CondExpOp(
enum CompareOp cop ,
const AD<Base> &left ,
const AD<Base> &right ,
const AD<Base> &if_true ,
const AD<Base> &if_false )
{
AD<Base> returnValue;
CPPAD_ASSERT_UNKNOWN( Parameter(returnValue) );
// check first case where do not need to tape
if( IdenticalPar(left) & IdenticalPar(right) )
{ switch( cop )
{
case CompareLt:
if( left.value_ < right.value_ )
returnValue = if_true;
else returnValue = if_false;
break;
case CompareLe:
if( left.value_ <= right.value_ )
returnValue = if_true;
else returnValue = if_false;
break;
case CompareEq:
if( left.value_ == right.value_ )
returnValue = if_true;
else returnValue = if_false;
break;
case CompareGe:
if( left.value_ >= right.value_ )
returnValue = if_true;
else returnValue = if_false;
break;
case CompareGt:
if( left.value_ > right.value_ )
returnValue = if_true;
else returnValue = if_false;
break;
default:
CPPAD_ASSERT_UNKNOWN(0);
returnValue = if_true;
}
return returnValue;
}
// must use CondExp incase Base is an AD type and recording
returnValue.value_ = CondExpOp(cop,
left.value_, right.value_, if_true.value_, if_false.value_);
ADTape<Base> *tape = CPPAD_NULL;
if( Variable(left) )
tape = left.tape_this();
if( Variable(right) )
tape = right.tape_this();
if( Variable(if_true) )
tape = if_true.tape_this();
if( Variable(if_false) )
tape = if_false.tape_this();
// add this operation to the tape
if( tape != CPPAD_NULL )
tape->RecordCondExp(cop,
returnValue, left, right, if_true, if_false);
return returnValue;
}