Ejemplo n.º 1
0
        public virtual DMatrixRMaj getU(DMatrixRMaj U, bool transpose, bool compact)
        {
            U = BidiagonalDecompositionRow_DDRM.handleU(U, false, compact, m, n, min);

            if (compact)
            {
                // U = Q*U1
                DMatrixRMaj Q1 = decompQRP.getQ(null, true);
                DMatrixRMaj U1 = decompBi.getU(null, false, true);
                CommonOps_DDRM.mult(Q1, U1, U);
            }
            else
            {
                // U = [Q1*U1 Q2]
                DMatrixRMaj Q   = decompQRP.getQ(U, false);
                DMatrixRMaj U1  = decompBi.getU(null, false, true);
                DMatrixRMaj Q1  = CommonOps_DDRM.extract(Q, 0, Q.numRows, 0, min);
                DMatrixRMaj tmp = new DMatrixRMaj(Q1.numRows, U1.numCols);
                CommonOps_DDRM.mult(Q1, U1, tmp);
                CommonOps_DDRM.insert(tmp, Q, 0, 0);
            }

            if (transpose)
            {
                CommonOps_DDRM.transpose(U);
            }

            return(U);
        }
Ejemplo n.º 2
0
        public virtual DMatrixRMaj getB(DMatrixRMaj B, bool compact)
        {
            B = BidiagonalDecompositionRow_DDRM.handleB(B, compact, m, n, min);

            B.set(0, 0, this.B.get(0, 0));
            for (int i = 1; i < min; i++)
            {
                B.set(i, i, this.B.get(i, i));
                B.set(i - 1, i, this.B.get(i - 1, i));
            }
            if (n > m)
            {
                B.set(min - 1, min, this.B.get(min - 1, min));
            }

            return(B);
        }