code: private static double[] toArray(DoubleVector v, int length) {
          double[] arr = new double[length];
          for (int i = 0; i < arr.length; ++i) {
              arr[i] = v.get(i);
          }
          return arr;
      }
docs: Returns an array of the specified length using the data in the provided
  vector.  This method allows row vectors to be converted to arrays based
  on the size of the matrix at the time of the call, thereby prevent
  changes in length due to external vector modifications.