code: public void reshape(int newrows, int newcolumns) {
          if (((newrows == rows) && (newcolumns == columns)) || (newrows <= 0) || (newcolumns <= 0)) return;
  
          double[][] newrealmatrix = new double[newrows][newcolumns];
          double[][] newimagmatrix = new double[newrows][newcolumns];
          int minrows = Math.min(rows, newrows);
          int mincolumns = Math.min(columns, newcolumns);
          int i, j;
          for (i = 0; i < minrows; i++)
              for (j = 0; j < mincolumns; j++) {
                  newrealmatrix[i][j] = realmatrix[i][j];
                  newimagmatrix[i][j] = imagmatrix[i][j];
              }
  
          for (i = minrows; i < newrows; i++)
              for (j = 0; j < mincolumns; j++) {
                  newrealmatrix[i][j] = 0d;
                  newimagmatrix[i][j] = 0d;
              }
  
          for (i = 0; i < minrows; i++)
              for (j = mincolumns; j < newcolumns; j++) {
                  newrealmatrix[i][j] = 0d;
                  newimagmatrix[i][j] = 0d;
              }
  
          for (i = minrows; i < newrows; i++)
              for (j = mincolumns; j < newcolumns; j++) {
                  newrealmatrix[i][j] = 0d;
                  newimagmatrix[i][j] = 0d;
              }
  
          realmatrix = newrealmatrix;
          imagmatrix = newimagmatrix;
          rows = newrows;
          columns = newcolumns;
      }
docs: Resize the matrix