public void invert(DMatrixRBlock A_inv)
        {
            DMatrixRBlock T = decomposer.getT(null);

            if (A_inv.numRows != T.numRows || A_inv.numCols != T.numCols)
            {
                throw new ArgumentException("Unexpected number or rows and/or columns");
            }

            // zero the upper triangular portion of A_inv
            MatrixOps_DDRB.zeroTriangle(true, A_inv);

            DSubmatrixD1 L = new DSubmatrixD1(T);
            DSubmatrixD1 B = new DSubmatrixD1(A_inv);

            // invert L from cholesky decomposition and write the solution into the lower
            // triangular portion of A_inv
            // B = inv(L)
            TriangularSolver_DDRB.invert(blockLength, false, L, B, workspace);

            // B = L^-T * B
            // todo could speed up by taking advantage of B being lower triangular
            // todo take advantage of symmetry
            TriangularSolver_DDRB.solveL(blockLength, L, B, true);
        }
コード例 #2
0
        private bool decomposeUpper()
        {
            int blockLength = T.blockLength;

            subA.set(T);
            subB.set(T);
            subC.set(T);

            for (int i = 0; i < T.numCols; i += blockLength)
            {
                int widthA = Math.Min(blockLength, T.numCols - i);

                //@formatter:off
                subA.col0 = i; subA.col1 = i + widthA;
                subA.row0 = subA.col0; subA.row1 = subA.col1;

                subB.col0 = i + widthA; subB.col1 = T.numCols;
                subB.row0 = i; subB.row1 = i + widthA;

                subC.col0 = i + widthA; subC.col1 = T.numCols;
                subC.row0 = i + widthA; subC.row1 = T.numCols;
                //@formatter:on

                // cholesky on inner block A
                if (!InnerCholesky_DDRB.upper(subA))
                {
                    return(false);
                }

                // on the last block these operations are not needed.
                if (widthA == blockLength)
                {
                    // B = U^-1 B
                    TriangularSolver_DDRB.solveBlock(blockLength, true, subA, subB, true, false);

                    // C = C - B^T * B
                    InnerRankUpdate_DDRB.symmRankNMinus_U(blockLength, subC, subB);
                }
            }

            MatrixOps_DDRB.zeroTriangle(false, T);

            return(true);
        }