code: public static void FFTShift1D(double[] x, Direction direction) {
  
          if (x.length == 1)
              return;
  
          double[] temp = x.clone();
          int move = x.length / 2;
  
          if (direction == Direction.Forward) {
              int c = 0;
              for (int i = x.length - move; i < x.length; i++)
                  x[c++] = temp[i];
  
              for (int i = 0; i < x.length - move; i++)
                  x[c++] = temp[i];
  
          } else {
              int c = 0;
              for (int i = move; i < x.length; i++)
                  x[c++] = temp[i];
  
              for (int i = 0; i < move; i++)
                  x[c++] = temp[i];
  
          }
      }
docs: Shift zero-frequency component to center of spectrum.
  
  @param x         Data.
  @param direction Transformation direction.