当前位置: 首页>>代码示例>>C++>>正文


C++ Operand::Clone方法代码示例

本文整理汇总了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 )
			{
//.........这里部分代码省略.........
开发者ID:spencerparkin,项目名称:Junk,代码行数:101,代码来源:Product.cpp


注:本文中的Operand::Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。