/// <summary> /// Build an instance representing a variable. /// <para>Instances built using this constructor are considered /// to be the free variables with respect to which differentials /// are computed. As such, their differential with respect to /// themselves is +1.</para> /// </summary> /// <param name="parameters">number of free parameters</param> /// <param name="order">derivation order</param> /// <param name="index">index of the variable (from 0 to <c>parameters - 1</c>)</param> /// <param name="value">value of the variable</param> /// <exception cref="NumberIsTooLargeException"> if <c>index >= parameters</c>.</exception> /// <remarks> /// See <see cref="DerivativeStructure(int, int, double)"/> /// </remarks> public DerivativeStructure(int parameters, int order, int index, double value) : this(parameters, order, value) { if (index >= parameters) { throw new NumberIsTooLargeException <Int32, Int32>(index, parameters, false); } if (order > 0) { // the derivative of the variable with respect to itself is 1. data[DSCompiler.getCompiler(index, order).getSize()] = 1.0; } }
/// <summary> /// Build an instance with all values and derivatives set to 0. /// </summary> /// <param name="parameters">number of free parameters</param> /// <param name="order">derivation order</param> /// <exception cref="NumberIsTooLargeException"> if order is too large</exception> public DerivativeStructure(int parameters, int order) : this(DSCompiler.getCompiler(parameters, order)) { }