public void Evaluate(DifferentiableFunction function, Jet[] parameters, double[] values, double[][] jacobian) { if (this.index < this.domain) { throw new Exception("Insufficient parameters added"); } if (this.domain != parameters.Length) { throw new ArgumentException("Insufficient parameters provided"); } var f = new Jet[this.range]; function(f, parameters); for (int i = 0; i < this.range; ++i) { values[i] = f[i].Real; for (int j = 0; j < this.domain; ++j) { jacobian[i][j] = f[i].Infinitesimals[j]; } } }
public static bool IsNaN(Jet a) { if (IsNaN(a.r)) { return(true); } for (int i = 0; i < a.v.Length; ++i) { if (IsNaN(a.v[i])) { return(true); } } return(false); }
public static Jet Atan(Jet a) { return(new Jet(Atan(a.r), Multiply(a.v, 1.0 / (1.0 + a.r * a.r)))); }
public static Jet Acos(Jet a) { return(new Jet(Acos(a.r), Multiply(a.v, -1.0 / Sqrt(1.0 - a.r * a.r)))); }
public static Jet Asin(Jet a) { return(new Jet(Asin(a.r), Multiply(a.v, 1.0 / Sqrt(1.0 - a.r * a.r)))); }
public static Jet Tan(Jet a) { double t = Tan(a.r); return(new Jet(t, Multiply(a.v, 1.0 + t + t))); }
public static Jet Cos(Jet a) { return(new Jet(Cos(a.r), Multiply(a.v, -Sin(a.r)))); }
public static Jet Sin(Jet a) { return(new Jet(Sin(a.r), Multiply(a.v, Cos(a.r)))); }
public static Jet Sqrt(Jet a) { double t = Sqrt(a.r); return(new Jet(t, Multiply(a.v, 1.0 / (2.0 * t)))); }
public static Jet Sqr(Jet a) { return(new Jet(Sqr(a.r), Multiply(a.v, (2.0 * a.r)))); }
public static Jet Exp(Jet a) { double t = Exp(a.r); return(new Jet(t, Multiply(a.v, t))); }
public static Jet Log(Jet a) { double t = 1.0 / a.r; return(new Jet(Log(a.r), Multiply(a.v, t))); }
public static Jet Abs(Jet a) { return((a.r < 0.0) ? -a : a); }