Ejemplo n.º 1
0
 /// <summary>Initializes a new <see cref="ApproximatelyDifferentiableMDFunction"/> given an <see cref="IMultidimensionalFunction"/>
 /// whose gradient should be approximated using a forward-difference method, and the difference factor.
 /// </summary>
 /// <param name="function">The function whose gradient will be approximated.</param>
 /// <param name="factor">A very small positive quantity representing fractional amount by which each argument will be increased when
 /// computing the gradient. The default (used by <see cref="ApproximatelyDifferentiableVVFunction(IVectorValuedFunction)"/>) is
 /// 0.00000001 (i.e. 1e-8). Smaller values might give a better approximation, but are more susceptible to roundoff error.
 /// </param>
 public ApproximatelyDifferentiableMDFunction(IMultidimensionalFunction function, double factor)
 {
     if (function == null)
     {
         throw new ArgumentNullException();
     }
     if (factor <= 0)
     {
         throw new ArgumentOutOfRangeException();
     }
     this.function = function;
     this.input2   = new double[function.Arity]; // the array used to hold x+h
     this.factor   = factor;
 }
Ejemplo n.º 2
0
 /// <summary>Initializes a new <see cref="ApproximatelyDifferentiableMDFunction"/> given an <see cref="IMultidimensionalFunction"/>
 /// whose gradient should be approximated using a forward-difference method.
 /// </summary>
 public ApproximatelyDifferentiableMDFunction(IMultidimensionalFunction function) : this(function, 1e-8)
 {
 }