code: public static void shift2D(double[] a, int w, int h, int x, int y){
  		assertPositive(w, ()->"specified width is not positive. w="+w);
  		assertPositive(h, ()->"specified height is not positive. h="+h);
  		while(x < 0) x = w+x;
  		while(y < 0) y = h+y;
  		x %=w;
  		y %=h;
  		if(x==0 && y==0){
  			return;
  		}
  		for(int row = 0; row < h; row++){
  			int offset = row*w;
  			rotateArray(a, w, offset, x);
  		}
  		rotateArray(a,w*h, 0, y*w);
  	}
docs: Applies a 2D torus shift to the specified row major order array of specified dimensions.
  The array is interpreted as an image of given width and height (with elements in row major order)
  and is shifted by x to the right and by y to the bottom.
  @param a array
  @param w width
  @param h height
  @param x shift in x direction
  @param y shift in y direction