using System; namespace Science.Mathematics.VectorCalculus { public class Curl { private Function.ToLastType func; private Vector res = new Vector(3); private double[] at1; public Curl(Function.ToLastType f, double[] x) { if (x.Length != 3) try { throw new Science.Error(); } catch (Science.Error e) { e.Write("Bad dimension. Only 3 dimension is considered."); }; func = f; at1 = x; } public double[] At { set { at1 = value; } } private int cp; public void Compute() { res[0] = 0.0; res[1] = 0.0; res[2] = 0.0; Function.ToLastType part = new Function.ToLastType(comp); PartialDerivative obj; cp = 2; obj = new PartialDerivative(part, at1); obj.WithRespectTo = 1; obj.Compute(); res[0] += obj.Result; cp = 1; obj = new PartialDerivative(part, at1); obj.WithRespectTo = 2; obj.Compute(); res[0] -= obj.Result; cp = 0; obj = new PartialDerivative(part, at1); obj.WithRespectTo = 2; obj.Compute(); res[1] += obj.Result; cp = 2; obj = new PartialDerivative(part, at1); obj.WithRespectTo = 0; obj.Compute(); res[1] -= obj.Result; cp = 1; obj = new PartialDerivative(part, at1); obj.WithRespectTo = 0; obj.Compute(); res[2] += obj.Result; cp = 0; obj = new PartialDerivative(part, at1); obj.WithRespectTo = 1; obj.Compute(); res[2] -= obj.Result; } private double comp(double[] x) { return func(x)[cp]; } public Vector Result { get { return res; } } } }