/* (non-Javadoc)
@see net.finmath.integration.AbstractRealIntegral#integrate(java.util.function.DoubleUnaryOperator)
340060
@Override
	public double integrate(DoubleUnaryOperator integrand) {
		double	lowerBound			= getLowerBound();
		double	upperBound			= getUpperBound();
		double	range				= upperBound-lowerBound;

		// Create random number sequence generator (we use MersenneTwister)
		MersenneTwister		mersenneTwister		= new MersenneTwister(seed);

		double integral = 0.0;
		for(int i=0; i<numberOfEvaluationPoints; i++) {
			integral += integrand.applyAsDouble(lowerBound + mersenneTwister.nextDouble() * range);
		}

		return integral * range / numberOfEvaluationPoints;
	}
262714
@Override
    public double membership(double x) {
        if (Double.isNaN(x)) {
            return Double.NaN;
        }
        double mu = 0.0;
        for (Activated term : this.terms) {
            mu = this.aggregation.compute(mu, term.membership(x));
        }
        return mu;
    }
1287104
@Override
  public Double divide2(Double arg1, long arg2) {
    if (arg1 == null) {
      return Double.NaN;
    } else {
      return arg1 / arg2;
    }
  }
819481
private void assertUnaryOperator(final String operator) {
    if (!("+".equals(operator) || "-".equals(operator) || "~".equals(operator))) {
      throw new JBBPCompilationException("Wrong unary operator '" + operator + "' [" + this.expressionSource + ']');
    }
  }
371631
@javax.annotation.Nonnull
  public static List<double[]> op(@javax.annotation.Nonnull final List<double[]> a, @javax.annotation.Nonnull final DoubleUnaryOperator fn) {
    @javax.annotation.Nonnull final ArrayList<double[]> list = new ArrayList<>();
    for (int i = 0; i < a.size(); i++) {
      @javax.annotation.Nonnull final double[] c = new double[a.get(i).length];
      for (int j = 0; j < a.get(i).length; j++) {
        c[j] = fn.applyAsDouble(a.get(i)[j]);
      }
      list.add(c);
    }
    return list;
  }
966073
public static <T> UnaryOperator<T> unaryOperator(CheckedUnaryOperator<T> operator) {
        return unaryOperator(operator, THROWABLE_TO_RUNTIME_EXCEPTION);
    }
293425
public void add(DoubleArrayList values) {
        ensureCapacity(size + values.size);
        for (int i=0; i<values.size; i++) {
            this.add(values.elements[i]);
        }
    }
453876
private void initUnaryOperators() {
        initOperators(unaryOperators,
                new UnaryNumericOperator(Tag.POS)
                        .addUnaryOperator(DOUBLE, DOUBLE, nop)
                        .addUnaryOperator(FLOAT, FLOAT, nop)
                        .addUnaryOperator(LONG, LONG, nop)
                        .addUnaryOperator(INT, INT, nop),
                new UnaryNumericOperator(Tag.NEG)
                        .addUnaryOperator(DOUBLE, DOUBLE, dneg)
                        .addUnaryOperator(FLOAT, FLOAT, fneg)
                        .addUnaryOperator(LONG, LONG, lneg)
                        .addUnaryOperator(INT, INT, ineg),
                new UnaryNumericOperator(Tag.COMPL, Type::isIntegral)
                        .addUnaryOperator(LONG, LONG, lxor)
                        .addUnaryOperator(INT, INT, ixor),
                new UnaryPrefixPostfixOperator(Tag.POSTINC)
                        .addUnaryOperator(DOUBLE, DOUBLE, dadd)
                        .addUnaryOperator(FLOAT, FLOAT, fadd)
                        .addUnaryOperator(LONG, LONG, ladd)
                        .addUnaryOperator(INT, INT, iadd)
                        .addUnaryOperator(CHAR, CHAR, iadd)
                        .addUnaryOperator(SHORT, SHORT, iadd)
                        .addUnaryOperator(BYTE, BYTE, iadd),
                new UnaryPrefixPostfixOperator(Tag.POSTDEC)
                        .addUnaryOperator(DOUBLE, DOUBLE, dsub)
                        .addUnaryOperator(FLOAT, FLOAT, fsub)
                        .addUnaryOperator(LONG, LONG, lsub)
                        .addUnaryOperator(INT, INT, isub)
                        .addUnaryOperator(CHAR, CHAR, isub)
                        .addUnaryOperator(SHORT, SHORT, isub)
                        .addUnaryOperator(BYTE, BYTE, isub),
                new UnaryBooleanOperator(Tag.NOT)
                        .addUnaryOperator(BOOLEAN, BOOLEAN, bool_not),
                new UnaryReferenceOperator(Tag.NULLCHK)
                        .addUnaryOperator(OBJECT, OBJECT, nullchk));
    }
697144
@Override
	protected Union<T> translateToDataFlow(Operator<T> input1, Operator<T> input2) {
		return new Union<T>(input1, input2, unionLocationName);
	}
261380
@Override
  public Double divide1(Long arg1, long arg2) {
    if (arg1 == null) {
      return Double.NaN;
    } else {
      return arg1 / (double) arg2;
    }
  }
548586
@Override
    public double membership(double x) {
        if (Double.isNaN(x)) {
            return Double.NaN;
        }
        return height * Math.exp(-Math.abs(10.0 / width * (x - center)));
    }
800814
public static TerminalOp<Double, OptionalDouble>
    makeDouble(DoubleBinaryOperator operator) {
        Objects.requireNonNull(operator);
        class ReducingSink
                implements AccumulatingSink<Double, OptionalDouble, ReducingSink>, Sink.OfDouble {
            private boolean empty;
            private double state;

            public void begin(long size) {
                empty = true;
                state = 0;
            }

            @Override
            public void accept(double t) {
                if (empty) {
                    empty = false;
                    state = t;
                }
                else {
                    state = operator.applyAsDouble(state, t);
                }
            }

            @Override
            public OptionalDouble get() {
                return empty ? OptionalDouble.empty() : OptionalDouble.of(state);
            }

            @Override
            public void combine(ReducingSink other) {
                if (!other.empty)
                    accept(other.state);
            }
        }
        return new ReduceOp<Double, OptionalDouble, ReducingSink>(StreamShape.DOUBLE_VALUE) {
            @Override
            public ReducingSink makeSink() {
                return new ReducingSink();
            }
        };
    }
643683
@Override
  public Double sqrt2(Double arg1) {
    if (arg1 == null) {
      return Double.NaN;
    } else {
      return Math.sqrt(arg1);
    }
  }
492041
@PublicEvolving
	public void setDouble(ConfigOption<Double> key, double value) {
		setValueInternal(key.key(), value);
	}
789221
@Nonnull
	public static DoubleUnaryOperator dblUnaryOperatorFrom(Consumer<DoubleUnaryOperatorBuilder> buildingFunction) {
		DoubleUnaryOperatorBuilder builder = new DoubleUnaryOperatorBuilder();
		buildingFunction.accept(builder);
		return builder.build();
	}
168042
public ParameterizedOperator operator(Point2D.Double... controlPoints)
    {
        if (controlPoints.length != length)
        {
            throw new IllegalArgumentException("control-points length not "+length);
        }
        double[] cp = convert(controlPoints);
        return operator(cp);
    }
222327
public void add(double value) {
    count++;
    min = Math.min(min, value);
    max = Math.max(max, value);
    sum += value;
    sumOfSquares += value * value;
    addQuantileValue(value);
  }