	__host__ __device__ cuvec2i::cuvec2i() 
	{
		x = 0; y = 0; 
		return;
	}

	__host__ __device__ cuvec2i::~cuvec2i() 
	{
		x = 0; y = 0; 
		return;
	}

	__host__ __device__ cuvec2i::cuvec2i(const int &_x, const int &_y) 
	{
		x = _x; y = _y; 
		return;
	}

	__host__ __device__ int& cuvec2i::operator[](const int &I)
	{
		switch(I)
		{
			case 0:
				return x;
			case 1:
				return y;
		}

		return x;
	}

	__host__ __device__ const int& cuvec2i::operator[](const int &I) const
	{
		switch(I)
		{
			case 0:
				return x;
			case 1:
				return y;
		}

		return x;
	}

	__host__ __device__ cuvec2i cuvec2i::operator+(const cuvec2i& rhs) const
	{
		cuvec2i ret;
		ret.x = x + rhs.x;
		ret.y = y + rhs.y;
		return ret;
	}

	__host__ __device__ cuvec2i cuvec2i::operator-(const cuvec2i& rhs) const
	{
		cuvec2i ret;
		ret.x = x - rhs.x;
		ret.y = y - rhs.y;
		return ret;
	}

	__host__ __device__ cuvec2i cuvec2i::operator*(const cuvec2i& rhs) const
	{
		//Elementwise product
		cuvec2i ret;
		ret.x = x * rhs.x;
		ret.y = y * rhs.y;
		return ret;
	}

	__host__ __device__ cuvec2i cuvec2i::operator/(const cuvec2i& rhs) const
	{
		//Elementwise division
		cuvec2i ret;
		ret.x = x / rhs.x;
		ret.y = y / rhs.y;
		return ret;
	}

	__host__ __device__ cuvec2i operator*(const cuvec2i& lhs, const int& rhs)
	{
		cuvec2i ret;
		ret.x = lhs.x*rhs;
		ret.y = lhs.y*rhs;
		return ret;
	}

	__host__ __device__ cuvec2i operator*(const int& lhs, const cuvec2i& rhs)
	{
		cuvec2i ret;
		ret.x = lhs*rhs.x;
		ret.y = lhs*rhs.y;
		return ret;
	}

	__host__ __device__ cuvec2i operator/(const cuvec2i& lhs, const int& rhs)
	{
		cuvec2i ret;
		ret.x = lhs.x/rhs;
		ret.y = lhs.y/rhs;
		return ret;
	}

	__host__ __device__ cuvec2i operator/(const int& lhs, const cuvec2i& rhs)
	{
		cuvec2i ret;
		ret.x = lhs/rhs.x;
		ret.y = lhs/rhs.y;
		return ret;
	}

	__host__ __device__ cuvec2i operator-(const cuvec2i& other)
	{
		cuvec2i ret;
		ret.x = -other.x;
		ret.y = -other.y;
		return ret;
	}

	__host__ __device__ cuvec2i& cuvec2i::operator+=(const cuvec2i& rhs)
	{
		x += rhs.x;
		y += rhs.y;
		return *this;
	}

	__host__ __device__ cuvec2i& cuvec2i::operator-=(const cuvec2i& rhs)
	{
		x -= rhs.x;
		y -= rhs.y;
		return *this;
	}

	__host__ __device__ cuvec2i& cuvec2i::operator*=(const int& rhs)
	{
		x *= rhs;
		y *= rhs;
		return *this;
	}

	__host__ __device__ cuvec2i& cuvec2i::operator/=(const int& rhs)
	{
		x /= rhs;
		y /= rhs;
		return *this;
	}


//
//Matrix Header Stuff
//

	__host__ __device__ cumat2i::cumat2i() 
	{
		m00 = 0;
		m01 = 0;

		m10 = 0;
		m11 = 0;

		return;
	}

	__host__ __device__ cumat2i::~cumat2i() 
	{
		//m00 = 0;
		//m01 = 0;

		//m10 = 0;
		//m11 = 0;

		return;
	}

	__host__ __device__ cumat2i::cumat2i(
		const int& _m00, const int& _m01, 
		const int& _m10, const int& _m11
	)
	{
		m00 = _m00; 
		m10 = _m10; 

		m01 = _m01; 
		m11 = _m11; 


		return;
	}

	__host__ __device__ cumat2i::cumat2i(const int* data4)
	{
		m00 = data4[0]; 
		m10 = data4[1]; 

		m01 = data4[2]; 
		m11 = data4[3]; 


		return;
	}

	__host__ __device__ int& cumat2i::operator[](const int &I)
	{
		switch(I)
		{
			case 0:
				return m00;
			case 1:
				return m10;
			case 2:
				return m01;
			case 3:
				return m11;
		}

		return m00;
	}

	__host__ __device__ const int& cumat2i::operator[](const int &I) const
	{
		switch(I)
		{
			case 0:
				return m00;
			case 1:
				return m10;
			case 2:
				return m01;
			case 3:
				return m11;
		}

		return m00;
	}

	__host__ __device__ int& cumat2i::operator()(const int &I, const int &J)
	{
		return (*this)[I+2*J];
	}

	__host__ __device__ const int& cumat2i::operator()(const int &I, const int &J) const
	{
		return (*this)[I+2*J];
	}

	__host__ __device__ int& cumat2i::at(const int &I, const int &J)
	{
		return (*this)[I+2*J];
	}

	__host__ __device__ const int& cumat2i::at(const int &I, const int &J) const
	{
		return (*this)[I+2*J];
	}

__host__ __device__ int* cumat2i::data()
{
	return (int*)this;
}

__host__ __device__ const int* cumat2i::data() const
{
	return (int*)this;
}

__host__ __device__ cumat2i cumat2i::operator+(const cumat2i& rhs) const
{
	cumat2i ret;
	ret.m00 = m00 + rhs.m00;
	ret.m10 = m10 + rhs.m10;

	ret.m01 = m01 + rhs.m01;
	ret.m11 = m11 + rhs.m11;

	return ret;
}

__host__ __device__ cumat2i cumat2i::operator-(const cumat2i& rhs) const
{
	cumat2i ret;
	ret.m00 = m00 - rhs.m00;
	ret.m10 = m10 - rhs.m10;

	ret.m01 = m01 - rhs.m01;
	ret.m11 = m11 - rhs.m11;

	return ret;
}

__host__ __device__ cumat2i cumat2i::operator*(const cumat2i& rhs) const
{
	cumat2i ret; //should be zeroed in constructor
	ret.m00 = m00*rhs.m00 + m01*rhs.m10;
	ret.m01 = m00*rhs.m01 + m01*rhs.m11;

	ret.m10 = m10*rhs.m00 + m11*rhs.m10;
	ret.m11 = m10*rhs.m01 + m11*rhs.m11;

	return ret;
}

__host__ __device__ cumat2i operator*(const cumat2i& lhs, const int& rhs)
{
	cumat2i ret;
	ret.m00=lhs.m00*rhs;
	ret.m10=lhs.m10*rhs;
	ret.m01=lhs.m01*rhs;
	ret.m11=lhs.m11*rhs;
	return ret;
}

__host__ __device__ cumat2i operator/(const cumat2i& lhs, const int& rhs)
{
	cumat2i ret;
	ret.m00=lhs.m00/rhs;
	ret.m10=lhs.m10/rhs;
	ret.m01=lhs.m01/rhs;
	ret.m11=lhs.m11/rhs;
	return ret;
}

__host__ __device__ cumat2i operator*(const int& lhs, const cumat2i& rhs)
{
	cumat2i ret;
	ret.m00=lhs*rhs.m00;
	ret.m10=lhs*rhs.m10;
	ret.m01=lhs*rhs.m01;
	ret.m11=lhs*rhs.m11;
	return ret;
}

__host__ __device__ cuvec2i operator*(const cumat2i& lhs, const cuvec2i& rhs)
{
	cuvec2i ret;
	ret.x = lhs.m00*rhs.x + lhs.m01*rhs.y;
	ret.y = lhs.m10*rhs.x + lhs.m11*rhs.y;
	return ret;
}

__host__ __device__ cuvec2i operator*(const cuvec2i& lhs, const cumat2i& rhs)
{
	cuvec2i ret;
	ret.x = lhs.x*rhs.m00 + lhs.y*rhs.m10;
	ret.y = lhs.x*rhs.m01 + lhs.y*rhs.m11;
	return ret;
}

__host__ __device__ cumat2i operator-(const cumat2i& rhs)
{
	cumat2i ret;
	ret.m00 = -rhs.m00;
	ret.m10 = -rhs.m10;
	ret.m01 = -rhs.m01;
	ret.m11 = -rhs.m11;
	return ret;
}

__host__ __device__ cumat2i& cumat2i::operator+=(const cumat2i& rhs)
{
	m00 += rhs.m00;
	m10 += rhs.m10;
	m01 += rhs.m01;
	m11 += rhs.m11;
	return *this;
}

__host__ __device__ cumat2i& cumat2i::operator-=(const cumat2i& rhs)
{
	m00 -= rhs.m00;
	m10 -= rhs.m10;
	m01 -= rhs.m01;
	m11 -= rhs.m11;
	return *this;
}

__host__ __device__ cumat2i& cumat2i::operator*=(const int& rhs)
{
	m00 *= rhs;
	m10 *= rhs;
	m01 *= rhs;
	m11 *= rhs;
	return *this;
}

__host__ __device__ cumat2i& cumat2i::operator/=(const int& rhs)
{
	m00 /= rhs;
	m10 /= rhs;
	m01 /= rhs;
	m11 /= rhs;
	return *this;
}

__host__ __device__ cumat2i& cumat2i::operator*=(const cumat2i& rhs)
{
	cumat2i tmp = *this;
	m00 = tmp.m00*rhs.m00 + tmp.m01*rhs.m10;
	m01 = tmp.m00*rhs.m01 + tmp.m01*rhs.m11;
	m10 = tmp.m10*rhs.m00 + tmp.m11*rhs.m10;
	m11 = tmp.m10*rhs.m01 + tmp.m11*rhs.m11;
	return *this;
}

__host__ __device__ cumat2i cumat2i::transpose() const
{
	cumat2i ret;
	ret.m00 = m00;
	ret.m10 = m01;
	ret.m01 = m10;
	ret.m11 = m11;
	return ret;
}

