/// <summary>
 /// Creates an instance with a sampled (parameterised) curve.
 /// </summary>
 /// <param name="samplePoints">  the points where we sample the curve </param>
 /// <param name="curve">  a parameterised curve  </param>
 public ParameterizedCurveVectorFunction(double[] samplePoints, ParameterizedCurve curve)
 {
     ArgChecker.notEmpty(samplePoints, "samplePoints");
     ArgChecker.notNull(curve, "curve");
     _samplePoints = Arrays.copyOf(samplePoints, samplePoints.Length);
     _curve        = curve;
 }
        public override double?apply(double[] x)
        {
            ArgChecker.notEmpty(x, "x");
            if (x.Length == 1)
            {
                return(x[0]);
            }
            double sum = 0;

            foreach (double d in x)
            {
                sum += d;
            }
            return(sum / x.Length);
        }
Exemple #3
0
 /// <summary>
 /// {@inheritDoc}
 /// </summary>
 public virtual T integrate(System.Func <U, T> f, U[] lower, U[] upper)
 {
     ArgChecker.notNull(f, "function was null");
     ArgChecker.notNull(lower, "lower bound array was null");
     ArgChecker.notNull(upper, "upper bound array was null");
     ArgChecker.notEmpty(lower, "lower bound array was empty");
     ArgChecker.notEmpty(upper, "upper bound array was empty");
     ArgChecker.notNull(lower[0], "lower bound was null");
     ArgChecker.notNull(upper[0], "upper bound was null");
     if (lower.Length > 1)
     {
         log.info("Lower bound array had more than one element; only using the first");
     }
     if (upper.Length > 1)
     {
         log.info("Upper bound array had more than one element; only using the first");
     }
     return(integrate(f, lower[0], upper[0]));
 }