/*
    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 FILTRATOR_FILTRATOR2_H
#define FILTRATOR_FILTRATOR2_H
#include "matrices_all.h"
#include "options.h"

namespace filtrator2
{
	class Filtrator
	{
		public:
			Filtrator(const Params &p);
			void Start();
			void SimilarityStart();
		private:
			bool initialized;

			void LoadWords();

			void FilterColumns();
			void FilterRows();

			std::string getCurrentBoundary(Matrices::SuperMatrixPtr m, size_t colNo);
			void recalculateRowFeatures();
			void recalculateColumnFeatures();

			void WriteMatrixColumnBased();
			void PrepareFeaturesColumnBased(Matrices::CRSMatrixPtr pCRS);

			bool DimensionsChanged();
			bool FeatureCheck(const Matrices::Feature f) const;

			std::set<std::string> m_setWords;
			Params m_Params;

			size_t max_iter;
			bool untilStable;

			bool filterRowsOnly;
			bool filterColumnsOnly;

			std::string inMatrixDir;
			std::string inMatrixName;

			std::string outMatrixDir;
			std::string outMatrixName;

			Matrices::FeatureVectorPtr m_pvRowFeatures;
			Matrices::FeatureVectorPtr m_pvColumnFeatures;
			std::vector<size_t> filteredColumns;
			std::vector<size_t> filteredRows;

			boost::shared_ptr<Matrices::SuperMatrix> inMatrix;
			boost::shared_ptr<Matrices::SuperMatrix> outMatrix;

			size_t mintf;
			size_t minTF;
			size_t minnz;
			double minentropy;

			size_t maxtf;
			size_t maxTF;
			size_t maxnz;
			double maxentropy;

	};
}//namespace filtrator

#endif //FILTRATOR_FILTRATOR_H

