code: private static void enlargeTables(float[][] data, int[][] rowIndex, int cols, int currentRow, int currentCol) {
          while (data[currentRow].length < currentCol + cols) {
              if(data[currentRow].length == SPARSE_MATRIX_DIM) {
                  currentCol = 0;
                  cols -= (data[currentRow].length - currentCol);
                  currentRow++;
                  data[currentRow] = malloc4f(ALLOCATED_ARRAY_LEN);
                  rowIndex[currentRow] = malloc4(ALLOCATED_ARRAY_LEN);
              } else {
                  int newLen = (int) Math.min((long) data[currentRow].length << 1L, (long) SPARSE_MATRIX_DIM);
                  data[currentRow] = Arrays.copyOf(data[currentRow], newLen);
                  rowIndex[currentRow] = Arrays.copyOf(rowIndex[currentRow], newLen);
              }
          }
      }
docs: Assumes both matrices are getting filled at the same rate and will require the same amount of space