Exemple #1
0
        private Matrix4x4 ComputeTransform(double[,] A, double[] b)
        {
            double[,] Aplus = ArrayMatrixUtils.MoorePenroseInverse(A);
            double[] xOpt = ArrayMatrixUtils.Multiply(Aplus, b);

            return(TransformationMatrixFromXOpt(xOpt));
        }
        public void Test_MoorePenroseInverse_SquareMatrix()
        {
            double[,] array =
            {
                { -6.040000000000000, +4.880000000000000 },
                { -9.390000000000001, +0.000000000000001 },
            };

            double[,] expected =
            {
                { +0.000000000000000, -0.106496272630458 },
                { +0.204918032786885, -0.131810960386878 },
            };

            double[,] actual = ArrayMatrixUtils.MoorePenroseInverse(array);

            Assert.That(actual, Is.EqualTo(expected).Within(precision));
        }
        public void Test_MoorePenroseInverse_RectangularMatrix()
        {
            double[,] array =
            {
                { +5.5800, +7.8200 },
                { +4.3000, -3.3200 },
                { +8.0700, +3.9700 },
            };

            double[,] expected =
            {
                { +0.0017, +0.0921, +0.0737 },
                { +0.0878, -0.1020, -0.0063 },
            };

            double[,] actual = ArrayMatrixUtils.MoorePenroseInverse(array);

            Assert.That(actual, Is.EqualTo(expected).Within(precision));
        }