/// <summary> /// Computes the gradient of the compiled term at the given point. /// </summary> /// <param name="arg">The point at which to differentiate.</param> /// <param name="parameters">The parameter values</param> /// <returns>A tuple, where the first item is the gradient at <paramref name="arg"/> and the second item is /// the value at <paramref name="arg"/>. That is, the second value is the same as running <see cref="Evaluate"/> on /// <paramref name="arg"/> and <paramref name="parameters"/>.</returns> /// <remarks>The number at <c>arg[i]</c> is the value assigned to the variable <c>Variables[i]</c>.</remarks> public static Tuple <double[], double> Differentiate(this IParametricCompiledTerm term, IReadOnlyList <double> arg, IReadOnlyList <double> parameters) { var grad = new double[arg.Count]; var val = term.Differentiate(arg, parameters, grad); return(Tuple.Create(grad, val)); }
public Result(IParametricCompiledTerm lagrangian, ICompiledTerm[] constraints) { this.lagrangian = lagrangian; this.constraints = constraints; }