/*
    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 MATRICESLIB_IO_CCSCONVERT_H
#define MATRICESLIB_IO_CCSCONVERT_H

#include "../matrices_headers.h"
#include "../Matrix.h"

namespace Matrices
{
	namespace IO
	{
		class MATRICES_API CCSConverter
		{
		public:
			CCSConverter(bool showMsg = true, std::ostream &log = std::cout);
			~CCSConverter();

			/// Nie filtruje!
			void MatrixToCCS(Matrices::Matrix &matrix, std::vector<size_t> &rowind, std::vector<size_t> &colptrs, 
				std::vector<double> &vals, size_t &nz);

			/**
			Filtruje gdy jest ustawiony filter.

			\param matrix Macierz z ustawionym deskryptorem
			\throw std::runtime_error w przypadku bledu filtrowania
			*/
			void CCSToMatrix(Matrices::Matrix &matrix, std::vector<size_t> &rowind, 
				 std::vector<size_t> &colptrs, std::vector<double> &vals);

		private:
			bool m_bShowMsg;
			std::ostream &logout;

			Matrices::Matrix *m_Matrix;

			std::vector<size_t> *rowind;
			std::vector<size_t> *colptrs;
			std::vector<double> *vals;

			double* DecompressCol(size_t colNo);
			void CreateFromMatrix();
		};
	}
}



#endif
