Exemplo n.º 1
0
        public void ExceptionDifferentRowCount()
        {
            var matrixA = new Matrix(2, 2);
            matrixA[0, 0] = 0;
            matrixA[0, 1] = 0;
            matrixA[1, 0] = 1;
            matrixA[1, 1] = 0;

            var matrixB = new Matrix(2, 2);
            matrixB[0, 0] = 0;
            matrixB[0, 1] = 0;
            matrixB[1, 0] = 0;
            matrixB[1, 1] = 1;

            var qrDecomposition = new QRDecomposition(matrixA);
            qrDecomposition.Solve(matrixB);
        }
Exemplo n.º 2
0
        public void ExceptionRankDeficient()
        {
            var matrixA = new Matrix(3, 2);

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

            var matrixB = new Matrix(2, 2);
            matrixB[0, 0] = 0;
            matrixB[0, 1] = 0;
            matrixB[1, 0] = 0;
            matrixB[1, 1] = 1;

            var qrDecomposition = new QRDecomposition(matrixA);
            qrDecomposition.Solve(matrixB);
        }
Exemplo n.º 3
0
        public void Simple()
        {
            var matrixA = new Matrix(3, 2);

            matrixA[0, 0] = 1;
            matrixA[0, 1] = 2;

            matrixA[1, 0] = 3;
            matrixA[1, 1] = 4;

            matrixA[2, 0] = 4;
            matrixA[2, 1] = 2;

            var matrixB = new Matrix(3, 2);

            matrixB[0, 0] = 3;
            matrixB[0, 1] = 4;

            matrixB[1, 0] = 4;
            matrixB[1, 1] = 2;

            matrixB[2, 0] = 1;
            matrixB[2, 1] = 2;

            var decomposition = new QRDecomposition(matrixA);
            var solveMatrix = decomposition.Solve(matrixB);

            Assert.AreEqual(solveMatrix.Rows, 2);
            Assert.AreEqual(solveMatrix.Columns, 2);

            Assert.AreEqual(solveMatrix[0, 0], -0.514285714, 0.00000001);
            Assert.AreEqual(solveMatrix[0, 1], -0.057142857, 0.00000001);

            Assert.AreEqual(solveMatrix[1, 0], 1.4714285714, 0.00000001);
            Assert.AreEqual(solveMatrix[1, 1], 0.8857142857, 0.00000001);
        }