/*
    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 SVDRUNNER_H
#define SVDRUNNER_H
#include <string>
#include <iomanip>
#include "config.h"
#include "matrices_all.h"
#include <boost/algorithm/string.hpp>

class SVDRunner
{
public:
	/**
	  * Global run function
	  */
	void Start();
	/**
	  * Constructorgetting all values from config
	  */
	SVDRunner();
private:
	/**
	  * Function multiplying 2 CRS matrices
	  */
	Matrices::CRSMatrixPtr multiplyMatrices(Matrices::CRSMatrixPtr matrix1, Matrices::CRSMatrixPtr matrix2);
	/**
	  * Function responsible for matrix multiplications as part of SVD
	  */
	Matrices::CRSMatrixPtr multiplications();
	/**
	  * Function running svd until it produces desired number of dimensions in the middle matrix
	  */
	void getDesiredDimensions();
	/**
	  * Function loading SVD output to CRS matrices
	  */
	void loadMatrices();
	int iterations;
	int dimensions;
	std::string svdPath;
	std::string workDir;
	std::string matrixPath;
	std::string output;
	Matrices::CRSMatrixPtr UCRS;
	Matrices::CRSMatrixPtr SCRS;
	Matrices::CRSMatrixPtr VCRS;

};

#endif // SVDRUNNER_H
