本文整理汇总了C++中Operand::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ Operand::Clone方法的具体用法?C++ Operand::Clone怎么用?C++ Operand::Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operand
的用法示例。
在下文中一共展示了Operand::Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/*virtual*/ bool Product::Combine( const Operand* leftOperand, const Operand* rightOperand, Operand** resultOperand ) const
{
const NumericReal* leftNumericReal = dynamic_cast< const NumericReal* >( leftOperand );
const NumericReal* rightNumericReal = dynamic_cast< const NumericReal* >( rightOperand );
if( leftNumericReal )
{
if( leftNumericReal->real == 0.0 )
{
*resultOperand = leftNumericReal->Clone();
return true;
}
else if( leftNumericReal->real == 1.0 )
{
*resultOperand = rightOperand->Clone();
return true;
}
}
if( rightNumericReal )
{
if( rightNumericReal->real == 0.0 )
{
*resultOperand = rightNumericReal->Clone();
return true;
}
else if( rightNumericReal->real == 1.0 )
{
*resultOperand = leftOperand->Clone();
return true;
}
}
if( leftNumericReal && rightNumericReal )
{
NumericReal* numericReal = new NumericReal();
numericReal->real = leftNumericReal->real * rightNumericReal->real;
return true;
}
const SymbolicReal* leftSymbolicReal = dynamic_cast< const SymbolicReal* >( leftOperand );
const SymbolicReal* rightSymbolicReal = dynamic_cast< const SymbolicReal* >( rightOperand );
if( leftNumericReal && rightSymbolicReal )
{
SymbolicReal* symbolicReal = ( SymbolicReal* )rightSymbolicReal->Clone();
if( !symbolicReal->scalar )
symbolicReal->scalar = leftNumericReal->Clone();
else
{
GeometricProduct* geometricProduct = new GeometricProduct();
geometricProduct->operandList.InsertAfter()->data = leftNumericReal->Clone();
geometricProduct->operandList.InsertAfter()->data = symbolicReal->scalar;
symbolicReal->scalar = geometricProduct;
}
}
if( leftSymbolicReal && rightNumericReal )
{
SymbolicReal* symbolicReal = ( SymbolicReal* )leftSymbolicReal->Clone();
if( !symbolicReal->scalar )
symbolicReal->scalar = rightNumericReal->Clone();
else
{
GeometricProduct* geometricProduct = new GeometricProduct();
geometricProduct->operandList.InsertAfter()->data = symbolicReal->scalar;
geometricProduct->operandList.InsertAfter()->data = rightNumericReal->Clone();
symbolicReal->scalar = geometricProduct;
}
}
if( leftSymbolicReal && rightSymbolicReal && 0 == strcmp( leftSymbolicReal->name, rightSymbolicReal->name ) )
{
Operand* leftScalar = leftSymbolicReal->scalar;
Operand* rightScalar = rightSymbolicReal->scalar;
Operand* scalar = nullptr;
if( leftScalar && rightScalar )
{
GeometricProduct* geometricProduct = new GeometricProduct();
geometricProduct->operandList.InsertAfter()->data = leftScalar->Clone();
geometricProduct->operandList.InsertAfter()->data = rightScalar->Clone();
scalar = geometricProduct;
}
else if( leftScalar )
scalar = leftScalar->Clone();
else if( rightScalar )
scalar = rightScalar->Clone();
int exponent = leftSymbolicReal->exponent + rightSymbolicReal->exponent;
if( exponent == 0 )
{
if( !scalar )
{
//.........这里部分代码省略.........