#ifndef DOUBLET_HXX
# define DOUBLET_HXX


template<class T>
class doublet	{
	T d[2];
	public:
	T& operator[](int i)	{return d[i];}
	T operator[](int i)	const {return d[i];}
	T x() const	{return d[0];}
	T y() const	{return d[1];}
	doublet(T xx, T yy)	{d[0]=xx; d[1]=yy;}
	doublet(const doublet<T>& a)	{d[0]=a[0];d[1]=a[1];}
	doublet()	{d[0] = d[1] = 0;}
	doublet<T>& operator=(const doublet<T>& a)
		{d[0]=a[0]; d[1]=a[1]; return *this;}
	};

template<class T>
inline doublet<T> operator+(const doublet<T>& a, const doublet<T>& b);
template<class T>
inline doublet<T> operator*(T a, const doublet<T>& b);
template<class T>
inline doublet<T> operator*(const doublet<T>& b, T a);



/* inline bodies */
template<class T>
inline doublet<T> operator+(const doublet<T>& a, const doublet<T>& b)
	{return doublet<T>(a.x()+b.x(), a.y()+b.y());}
template<class T>
inline doublet<T> operator*(T a, const doublet<T>& b)
	{return doublet<T>(a*b.x(), a*b.y());}
template<class T>
inline doublet<T> operator*(const doublet<T>& b, T a)
	{return doublet<T>(a*b.x(), a*b.y());}

#endif
