コード例 #1
0
ファイル: Multivector.cpp プロジェクト: mapleyustat/GACompute
bool Multivector::AssignSum( const Multivector& multivectorA, const Multivector& multivectorB )
{
	if( this == &multivectorA && this == &multivectorB )
	{
		Scalar scalarTwo;
		if( !scalarTwo.Assign( 2.0 ) )
			return false;

		if( !AssignScalarProduct( scalarTwo, *this ) )
			return false;

		return true;
	}
	
	bool accumulateA = true;
	bool accumulateB = true;

	if( this == &multivectorA )
		accumulateA = false;
	else if( this == &multivectorB )
		accumulateB = false;
	else
		sumOfTerms.RemoveAll();

	if( accumulateA )
	{
		for( const SumOfTerms::Node* node = multivectorA.sumOfTerms.Head(); node; node = node->Next() )
		{
			const Term* term = node->data;
			sumOfTerms.InsertAfter()->data = term->Clone();
		}
	}

	if( accumulateB )
	{
		for( const SumOfTerms::Node* node = multivectorB.sumOfTerms.Head(); node; node = node->Next() )
		{
			const Term* term = node->data;
			sumOfTerms.InsertAfter()->data = term->Clone();
		}
	}

	if( !CollectTerms( Term::OUTER_PRODUCT ) )
		return false;

	return true;
}