using System; namespace Science.Mathematics.VectorCalculus { public class PartialDerivative { private Function.ToLastType dela; private Function.ToLastType del; private double[] origin; public PartialDerivative(Function.ToLastType func, double[] at) { dela = func; origin = new double[at.Length]; for (int i = 0; i < origin.Length; i++) origin[i] = at[i]; } public void Compute() { at = new double[origin.Length]; for (int i = 0; i < origin.Length; i++) at[i] = origin[i]; del = new Function.ToLastType(OneComponent); double y = at[comp]; Differentiation obj = new Differentiation(del,y); obj.Compute(); result = obj.Result; } private double OneComponent(double x) { at[comp] = x; return dela(at); } private double result; private double[] at; public double[] At { set { origin = value; } } public double Result { get { return result; } } private int comp; public int WithRespectTo { get { return comp; } set { comp = value; } } } }