コード例 #1
0
ファイル: CurveLine.cs プロジェクト: lyasotadv/CurveBuilder
        public virtual void LQR(double[] X, double[] Y)
        {
            if (X.Length != Y.Length)
            {
                return;
            }

            int N = X.Length;
            int M = order;

            RectangleMatrix A = new RectangleMatrix(N, M);
            Vector          B = new Vector(N);

            for (int n = 0; n < N; n++)
            {
                B[n] = C;
                for (int m = 0; m < M; m++)
                {
                    A[n, m] = phi[m](X[n], Y[n]);
                }
            }

            Vector V = A.LQR(B);

            for (int n = 0; n < order; n++)
            {
                a[n] = V[n];
            }
        }
コード例 #2
0
        public void LQRTest()
        {
            RectangleMatrix target = new RectangleMatrix(5, 2); // TODO: инициализация подходящего значения
            Vector          v      = new Vector(5);             // TODO: инициализация подходящего значения

            target[0, 0] = 0;
            target[1, 0] = 1;
            target[2, 0] = 2;
            target[3, 0] = 3;
            target[4, 0] = 4;

            target[0, 1] = 1;
            target[1, 1] = 1;
            target[2, 1] = 1;
            target[3, 1] = 1;
            target[4, 1] = 1;

            v[0] = 0;
            v[1] = 2;
            v[2] = 0;
            v[3] = 2;
            v[4] = 0;

            Vector actual;

            actual = target.LQR(v);
            Assert.AreEqual(Math.Round(actual[0], 1), 0.0);
            Assert.AreEqual(Math.Round(actual[1], 1), 0.8);
        }
コード例 #3
0
ファイル: Circle.cs プロジェクト: lyasotadv/CurveBuilder
        public override void LQR(double[] X, double[] Y)
        {
            if (X.Length != Y.Length)
            {
                return;
            }

            int N = X.Length;
            int M = order - 1;

            RectangleMatrix A = new RectangleMatrix(N, M);
            Vector          B = new Vector(N);

            for (int n = 0; n < N; n++)
            {
                B[n] = -phi[0](X[n], Y[n]);
                for (int m = 0; m < M; m++)
                {
                    A[n, m] = phi[m + 1](X[n], Y[n]);
                }
            }

            Vector V = A.LQR(B);

            for (int n = 0; n < M; n++)
            {
                a[n + 1] = V[n];
            }

            a[0] = 1.0;

            x0 = a[1];
            y0 = a[2];

            R = Math.Sqrt(x0 * x0 + y0 * y0 - a[3]);
        }