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

/*
 * vector_definitions.h
 *
 *  Created on: Apr 19, 2009
 *      Author: boban
 */

#ifndef VECTOR_DEFINITIONS_H_
#define VECTOR_DEFINITIONS_H_

#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>

class BaseVector {
public:
	virtual ~BaseVector();
	virtual void Weight();// podzili przez dlugosc
	virtual void SetValues(std::map<size_t, double> & vals) = 0;
	virtual double Length() = 0;
	virtual void DivByValue(double val) = 0;
	virtual double Cosine(BaseVector* other) = 0;
	virtual void Print() = 0;

};

class MapVector: public BaseVector {
public:
	std::map<size_t, double> values;
	virtual void SetValues(std::map<size_t, double> & vals);
	virtual double Length();
	virtual void DivByValue(double val);
	virtual double Cosine(BaseVector* other);
	virtual void Print();
};

class DoubleArrayVector: public BaseVector {
public:
	DoubleArrayVector();
	~DoubleArrayVector();
	double *m_pValues;
	size_t *m_pIndices;
	size_t m_stArraysLength;
	virtual void SetValues(std::map<size_t, double> & vals);
	virtual double Length();
	virtual void DivByValue(double val);
	virtual double Cosine(BaseVector* other);
	virtual void Print();
};

class DoubleVector: BaseVector {
public:
	std::vector<double> m_vData;
	std::vector<size_t> m_vIndices;
	virtual void SetValues(std::map<size_t, double> & vals);
	virtual double Length();
	virtual void DivByValue(double val);
	virtual double Cosine(BaseVector* other);
	virtual void Print();
};

template<class S>
class BoostMappedVector: public BaseVector {
public:
	boost::numeric::ublas::mapped_vector<double, S> vector;
	virtual void SetValues(std::map<size_t, double> & vals);
	virtual double Length();
	virtual void DivByValue(double val);
	virtual double Cosine(BaseVector* other);
	virtual void Print();
};

class BoostCompressedVector: public BaseVector {
public:
	boost::numeric::ublas::compressed_vector<double,0> vector;
	virtual void SetValues(std::map<size_t, double> & vals);
	virtual double Length();
	virtual void DivByValue(double val);
	virtual double Cosine(BaseVector* other);
	virtual void Print();
};

#endif /* VECTOR_DEFINITIONS_H_ */
