 			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
+
 		}
 	}
 

	TRY( VecGetLocalSize(layout,&Tlocal) );
	TRY( VecGetOwnershipRange(layout,&Tbegin,&Tend) );
	TRY( VecDestroy(&layout) ); /* destroy testing vector - it is useless now */
		
	TRY( VecCreateMPI(PETSC_COMM_WORLD,K*Tlocal,K*T, &x_Vec) );

	GeneralVector<PetscVector> x(x_Vec);
	GeneralVector<PetscVector> y(x); /* result, i.e. y = A*x */

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