code: public static void Forward(double[][] data) {
          int rows = data.length;
          int cols = data[0].length;
  
          double[] row = new double[cols];
          double[] col = new double[rows];
  
          for (int i = 0; i < rows; i++) {
              for (int j = 0; j < row.length; j++)
                  row[j] = data[i][j];
  
              Forward(row);
  
              for (int j = 0; j < row.length; j++)
                  data[i][j] = row[j];
          }
  
          for (int j = 0; j < cols; j++) {
              for (int i = 0; i < col.length; i++)
                  col[i] = data[i][j];
  
              Forward(col);
  
              for (int i = 0; i < col.length; i++)
                  data[i][j] = col[i];
          }
      }
docs: 2-D Forward Discrete Cosine Transform.
  
  @param data Data.