Exemplo n.º 1
0
//=========================================================================================
bool Matrix::AssignProduct( const Matrix& left, const Matrix& right )
{
	if( !left.table || !right.table )
		return false;

	if( this == &left || this == &right )
		return false;

	if( left.cols != right.rows )
		return false;

	if( !( rows == left.rows && cols == right.cols ) && !ReallocateMemory( left.rows, right.cols ) )
		return false;

	Element element;
	for( int row = 0; row < rows; row++ )
	{
		for( int col = 0; col < cols; col++ )
		{
			table[ row ][ col ].AssignScalar( 0.0 );
			for( int index = 0; index < left.cols; index++ )
			{
				if( !element.AssignProduct( left.table[ row ][ index ], right.table[ index ][ col ] ) )
					return false;

				if( !table[ row ][ col ].Accumulate( element ) )
					return false;
			}
		}
	}

	return true;
}