/*
    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 SUPERMATRIXFILTER_H
#define SUPERMATRIXFILTER_H
#include "matrices_headers.h"
#include "SuperMatrix.h"

namespace Matrices
{
	/**
	  * Removes given rows and columns from the given matrix.
	  *
	  * \note This function is not optimal in terms of execution time. It removes rows from CRS matrix,
	  *       then it copies it to CCS, removes columns from CCS and finaly copies it again to CRS.
	  *
	  * \param pMatrix matrix to filter
	  * \param erase_row_indices indices of rows to erase
	  * \param erase_column_indices indices of columns to erase
	  * \param update_features if set to true then will update term frequency and entropy of each feature; if
	  *        set to false, then features will be copied
	  * \param output_crs if set to true, then output SuperMatrixPtr will have crs matrix
	  * \param output_ccs if set to true, then output SuperMatrixPtr will have ccs matrix
	  * \param update_tf if set to true and update_feautes is set to true, then features will have tf recallculated as a sums of rows
	  */
	SuperMatrixPtr FilterSuperMatrix(SuperMatrixPtr pMatrix, std::set<size_t> &erase_row_indices,
									 std::set<size_t> &erase_column_indices, bool update_features = true,
									 bool output_crs = true, bool output_ccs = true, bool update_tf = true);


	std::map<size_t, std::string> UpdateBoundaries(SuperMatrixPtr pOldMatrix, std::set<size_t> &erased_column_indices);
	CCSMatrixPtr FilterCCS(CCSMatrixPtr pMatrix, std::set<size_t> &erase_column_indices);
	CRSMatrixPtr FilterCRS(CRSMatrixPtr pMatrix, std::set<size_t> &erase_row_indices);

}// namespace Matrices

#endif // SUPERMATRIXFILTER_H
