code: public void reshape(int newsize) {
          if ((newsize == size) || (newsize <= 0)) return;
  
          double[] newrealvector = new double[newsize];
          double[] newimagvector = new double[newsize];
          int min = Math.min(size, newsize);
          int i;
          for (i = 0; i < min; i++) {
              newrealvector[i] = realvector[i];
              newimagvector[i] = imagvector[i];
          }
          for (i = min; i < newsize; i++) {
              newrealvector[i] = 0d;
              newimagvector[i] = 0d;
          }
  
          realvector = newrealvector;
          imagvector = newimagvector;
          size = newsize;
      }
docs: Resize this vector