using System; namespace Science.Mathematics.VectorCalculus { public class Gradient { private Function.ToLastType func; private double[] res; private double[] at1; private int n; public Gradient(Function.ToLastType f, double[] x) { n = x.Length; func = f; res = new double[n]; at1 = x; } public double[] At { set { at1 = value; } } public void Compute() { PartialDerivative obj = new PartialDerivative(func, at1); for (int j = 0; j < n; j++) { obj.WithRespectTo = j; obj.Compute(); res[j] = obj.Result; } } public double[] Result { get { return res; } } } }