docs: public static double[] flatten(double[][] array) {
      int size = 0;
      for (double[] a : array) {
        size += a.length;
      }
      double[] newArray = new double[size];
      int i = 0;
      for (double[] a : array) {
        for (double d : a) {
          newArray[i++] = d;
        }
      }
      return newArray;
    }