class DoubleArrayMath {

  public static double[] combineLenient(double[] array1, double[] array2, DoubleBinaryOperator operator) {
    int len1 = array1.length;
    int len2 = array2.length;
    if (len1 == len2) {
      return combine(array1, array2, operator);
    }
    int size = Math.max(len1, len2);
    double[] result = new double[size];
    for (int i = 0; i < size; i++) {
      if (i < len1) {
        if (i < len2) {
          result[i] = operator.applyAsDouble(array1[i], array2[i]);
        } else {
          result[i] = array1[i];
        }
      } else {
        result[i] = array2[i];
      }
    }
    return result;
  }

  private  DoubleArrayMath();

}