//#  eulerN -- program for statistical estimation of Euler characteristic of a 3-dimensional body
//#  given as a sufficiently dense "volumetric" point sampling
//#
//#  Copyright (c) 2005-2007 Bradford Jones, Konstantin Rybnikov, Karen Daniels, Daniel Klain
//#  Release 2: 1 June 2007 
//#
//#  This program is free software; you can redistribute it and/or modify it
//#  under the terms of the GNU General Public License as published by the
//#  Free Software Foundation; either version 2, or (at your option) any
//#  later version: http://www.gnu.org/licenses/gpl.txt.
//#
//#  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
//#  GNU General Public License for more details.
//#-----------------------------------------------------------------------------


#ifndef M_VECTOR
#define M_VECTOR
#define MAX_DIM 4 /* <---- this can be safely changed to an INT >= 0  */

#include <math.h>
#include <iostream>
#include <cassert>
#include <ctime>
#include <cstdlib>
using namespace std;

// creating an instance of this class just seeds the C++ STL random number generator
class SeedRandomNumberGenerator
{
	public:
		SeedRandomNumberGenerator()
		{
			srand(static_cast<unsigned>(time(0)));
		}

};

class math_vector
{
	private:

		double data[MAX_DIM];
		int dimension;

		//Overloaded operators
		friend math_vector operator * (const math_vector&, double);
		friend math_vector operator * (double, const math_vector&);
		friend double operator * (const math_vector&, const math_vector&); //dot product
		friend ostream& operator << (ostream &os, const math_vector &v);
	public:
		static SeedRandomNumberGenerator seedRandomGenerator;
		/*--------------------------------------*/
		/// Constructors / destructor
		/*--------------------------------------*/
		math_vector();
		math_vector(int);
		math_vector(double, double);
		math_vector(double, double, double);
		math_vector(const math_vector&);
		~math_vector();
		/*--------------------------------------*/
		/// Class Functions
		/*--------------------------------------*/
		double xcoord();
		double ycoord();
		double zcoord();
		int dim() const;
		math_vector getRandomUnitVector(int dimension);
		math_vector norm();
		double length();
		double sqr_length();
		/*--------------------------------------*/
		/// Overloaded Operators
		/*--------------------------------------*/
		math_vector& operator = (const math_vector&);
		bool operator == (const math_vector&);
		bool operator != (const math_vector&);
		const double& operator[] (int) const;
		double& operator[] (int);
		math_vector operator + (const math_vector&);
		math_vector operator - (const math_vector&);
		math_vector operator / (double);
};

#endif
