 			TRY( PetscPrintf(PETSC_COMM_WORLD, "\n") );
 
 			/* restore array with values */
-			TRY( VecRestoreArray(y.get_vector(), &values) );
+			#ifndef USE_GPU
+				TRY( VecRestoreArray(y.get_vector(), &values) );
+			#else
+				TRY( VecCUDARestoreArrayReadWrite(y.get_vector(), &values) );
+			#endif
+
 		}
 	}
 

		
		if(test_view_matrix){
			/* get array of values */
			TRY( VecGetArray(y.get_vector(), &values) );
		
			/* print row */
			TRY( PetscPrintf(PETSC_COMM_WORLD, "%*d: ", 3, row_idx) );

		TRY( VecAssemblyBegin(x_Vec) );
		TRY( VecAssemblyEnd(x_Vec) );

		#ifndef USE_GPU
			TRY( VecGetArray(x_Vec,&gamma_arr) );
		#else
			TRY( VecCUDAGetArrayReadWrite(x_Vec,&gamma_arr) );
		#endif

		if(t >= Tbegin && t < Tend){
			tlocal = t - Tbegin;
			gamma_arr[tlocal + k*Tlocal] = 1;
		}

		#ifndef USE_GPU
			TRY( VecRestoreArray(x_Vec,&gamma_arr) );
		#else
			TRY( VecCUDARestoreArrayReadWrite(x_Vec,&gamma_arr) );
		#endif

		TRY( VecAssemblyBegin(x_Vec) );
		TRY( VecAssemblyEnd(x_Vec) );

