Ejemplo n.º 1
0
        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];
                }
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public static Jet Atan(Jet a)
 {
     return(new Jet(Atan(a.r), Multiply(a.v, 1.0 / (1.0 + a.r * a.r))));
 }
Ejemplo n.º 4
0
 public static Jet Acos(Jet a)
 {
     return(new Jet(Acos(a.r), Multiply(a.v, -1.0 / Sqrt(1.0 - a.r * a.r))));
 }
Ejemplo n.º 5
0
 public static Jet Asin(Jet a)
 {
     return(new Jet(Asin(a.r), Multiply(a.v, 1.0 / Sqrt(1.0 - a.r * a.r))));
 }
Ejemplo n.º 6
0
        public static Jet Tan(Jet a)
        {
            double t = Tan(a.r);

            return(new Jet(t, Multiply(a.v, 1.0 + t + t)));
        }
Ejemplo n.º 7
0
 public static Jet Cos(Jet a)
 {
     return(new Jet(Cos(a.r), Multiply(a.v, -Sin(a.r))));
 }
Ejemplo n.º 8
0
 public static Jet Sin(Jet a)
 {
     return(new Jet(Sin(a.r), Multiply(a.v, Cos(a.r))));
 }
Ejemplo n.º 9
0
        public static Jet Sqrt(Jet a)
        {
            double t = Sqrt(a.r);

            return(new Jet(t, Multiply(a.v, 1.0 / (2.0 * t))));
        }
Ejemplo n.º 10
0
 public static Jet Sqr(Jet a)
 {
     return(new Jet(Sqr(a.r), Multiply(a.v, (2.0 * a.r))));
 }
Ejemplo n.º 11
0
        public static Jet Exp(Jet a)
        {
            double t = Exp(a.r);

            return(new Jet(t, Multiply(a.v, t)));
        }
Ejemplo n.º 12
0
        public static Jet Log(Jet a)
        {
            double t = 1.0 / a.r;

            return(new Jet(Log(a.r), Multiply(a.v, t)));
        }
Ejemplo n.º 13
0
 public static Jet Abs(Jet a)
 {
     return((a.r < 0.0) ? -a : a);
 }