/*
    Copyright (C) 2012 Bartosz Broda, Jacek Bochenek, Łukasz Biłeńkij, 
    Damian Jaworski, Wojciech Mazur, Dominik Piasecki, Maciej Piasecki, 
    Radosław Ramocki
    
    This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.

    This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. 

    See the LICENSE and COPYING files for more details.
*/

//
// C++ Implementation: DoubleCompare
//
// Description:
//
//
// Author: Bartosz Broda <bartosz.broda@pwr.wroc.pl>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "../comparator_stdheaders.h"
#include "DoubleCompare.h"

namespace smartcomparator
{

	namespace compare
	{

		DoubleCompare::DoubleCompare ( CompareFunctionPtr firstOne, CompareFunctionPtr secondOne, double alpha, double beta)
			: CompareFunction(firstOne->GetMatrix()),
			m_pFirstOne(firstOne),
			m_pSecondOne(secondOne),
			m_dAlpha(alpha),
			m_dBeta(beta)
		{
		}


		DoubleCompare::~DoubleCompare()
		{
		}


		double DoubleCompare::Compare ( size_t n1, size_t n2 )
		{
			return m_dAlpha * m_pFirstOne->Compare(n1,n2) +
					m_dBeta * m_pSecondOne->Compare(n1,n2);
		}

		double DoubleCompare::MinValue() const
		{
			double min1 = m_pFirstOne->MinValue();
			double min2 = m_pSecondOne->MinValue();
			return min1*m_dAlpha + min2*m_dBeta;
		}

	}

}
