Esempio n. 1
0
        private OptVector[] GetApproximateInverseHessianMatrix(
            OptVector[] invHessian,
            OptVector yk,
            OptVector sk)
        {
            double denom = yk * sk;

            OptVector[] skyk = OptVector.Mult(sk, yk);
            OptVector[] yksk = OptVector.Mult(yk, sk);
            OptVector[] sksk = OptVector.Mult(sk, sk);

            OptVector[] v1 = OptVector.SubtractFromIdentity(OptVector.Div(skyk, denom));
            OptVector[] v2 = OptVector.SubtractFromIdentity(OptVector.Div(yksk, denom));
            OptVector[] v3 = OptVector.Div(sksk, denom);

            return(OptVector.Sum(OptVector.Mult(OptVector.Mult(v1, invHessian), v2), v3));
        }
Esempio n. 2
0
        public static OptVector Derivative(Func <double[], double> f, OptVector x)
        {
            double[] result = new double[x.Count];

            for (int i = 0; i < x.Count; i++)
            {
                OptVector v = new OptVector(x);

                result[i] = (f(OptVector.Min(v, h2, i).MinArray) - 8.0 * f(OptVector.Min(v, h, i).MinArray) + 8.0 * f(OptVector.Sum(v, h, i).MinArray) - f(OptVector.Sum(v, h2, i).MinArray)) /
                            (h2 * 6.0);
            }

            return(new OptVector(result));
        }