/*
    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.
*/

#ifndef SMARTCOMPARATOR_DISTANCEFUNCTION_H
#define SMARTCOMPARATOR_DISTANCEFUNCTION_H

#include "../comparator_stdheaders.h"

namespace smartcomparator
{
	namespace distances
	{
		/**
		Distance function - returns values from 0 (exact same point) to infinity (infinitely distant points)
		*/
		class SMART_COMPARATOR_API DistanceFunction
		{
		public:
			DistanceFunction(Matrices::SuperMatrixPtr m);
			virtual ~DistanceFunction(void);

			virtual double CountDistance(Matrices::CompressedVector& v1, Matrices::CompressedVector& v2,
				size_t v1ind, size_t v2ind,	const std::set<size_t> &v1Ind, const std::set<size_t> &v2Ind) = 0;

			virtual double MinValue() const = 0;

			/// Retruns true if a given function is symmetrical, i.e., sim(a,b) = sim(b,a); defaults to true
			virtual bool IsSymmetrical() const;

			/**
				uzupelnia wektory zerami
				\todo move outside to some helper module
			*/
			static void SetUnion(Matrices::CompressedVector &r1, Matrices::CompressedVector &r2,
				const std::set<size_t> &s1, const std::set<size_t> &s2,	std::set<size_t> &out, bool fillZeros = false);

			static void SetUnion(std::vector<size_t>::const_iterator &b1, std::vector<size_t>::const_iterator &e1,
				std::vector<size_t>::const_iterator &b2, std::vector<size_t>::const_iterator &e2,
				std::set<size_t> &out);

			static void SetUnion(std::set<size_t>::const_iterator &b1, std::set<size_t>::const_iterator &e1,
				std::set<size_t>::const_iterator &b2, std::set<size_t>::const_iterator &e2,
				std::set<size_t> &out);

		protected:
			Matrices::SuperMatrixPtr m_pMatrix;




		};
		typedef boost::shared_ptr<DistanceFunction> DistanceFunctionPtr;
	}
}
#endif //SMARTCOMPARATOR_SIMILAIRITYFUNCTION_H
