#ifndef _MATRIX_H_
#define _MATRIX_H_

#include <stdexcept>
#include <iostream>

namespace numeric {


/**This class represent a classical matrix of real
	The numbers are stored in a vector as FORTRAN do
	*/
class Matrix
{
	private:

		double **vector;
		unsigned dimRow;
		unsigned dimCol;
		unsigned incRow;
		unsigned incCol;

		static double ** matrixmultiply( const Matrix & , const Matrix & );
		static void _free(double **,unsigned );
    static double ** _allocate( unsigned ,unsigned );
    static double ** _allocate( unsigned ,unsigned ,const Matrix & );

	public:
		Matrix();
		Matrix(unsigned rows,unsigned cols);
		Matrix(unsigned n);
		Matrix(const Matrix & m);
		Matrix & operator=(const Matrix & m);

		inline unsigned getDimRow() const { return dimRow; }
		inline unsigned getDimCol() const { return dimCol; }
		double operator()(unsigned row, unsigned col) const;
		double & operator()(unsigned row, unsigned col);

		Matrix & rightProduct( const Matrix & other);
    Matrix & leftProduct(const Matrix & other);
		Matrix transpose();
};

std::ostream & operator<<( std::ostream & flux, const Matrix & a);

}

#endif
