 
 template<typename T>
 __global__
-void manipulateMatrix( coord_t<T>* input, std::size_t n, std::size_t m ) {
+void manipulateMatrix( coord_t<T>* input, std::size_t n, std::size_t m, std::size_t pitch ) {
 	const int row = blockIdx.x*blockDim.x+threadIdx.x;
 	if( row < n ) {
-		doSomethingToRow( input+(row*m), m );
+		doSomethingToRow( input+(row*pitch/sizeof(coord_t<T>)), m );
 	}
 	//const int x = blockIdx.x*blockDim.x+threadIdx.x / m;
 	//const int y = blockIdx.x*blockDim.x+threadIdx.x % m;

	deviceMatrix << hostMatrix;

	coord_t<double>* rawData = NULL;
	CUDA_CALL( cudaMalloc( reinterpret_cast<void**>(&rawData), N*N*sizeof(coord_t<double>) ) );
	CUDA_CALL( cudaMemcpy( reinterpret_cast<void*>(rawData), reinterpret_cast<const void*>(hostMatrix.data()), N*N*sizeof(coord_t<double>), cudaMemcpyHostToDevice ) );

	dim3 grid( (N+THREADS-1)/THREADS ), threads( THREADS );


		std::cout << "TIME (raw):  " << std::fixed << (stop-start) << std::endl;
		std::cout << "TIME (raw): " << std::fixed << ((timeEnd.tv_sec-timeStart.tv_sec)+(timeEnd.tv_nsec-timeStart.tv_nsec)/1e9) << std::endl;
		std::vector< coord_t<double> > results( N*N );
		CUDA_CALL( cudaMemcpy2D( &results.front(), N*sizeof(coord_t<double>), rawData, pitch, N*sizeof(coord_t<double>), N, cudaMemcpyDeviceToHost ) );
		std::cout << "[0,0]=" << std::fixed << results[0].x << "," << results[0].y << std::endl;
		std::cout << "[" << (N-1) << "," << (N-1) << "]=" << std::fixed << results.back().x << "," << results.back().y << std::endl;
	}
