//@Override
        public DMatrixSparseCSC getR(DMatrixSparseCSC R, bool compact)
        {
            if (R == null)
            {
                R = new DMatrixSparseCSC(0, 0, 0);
            }

            R.set(this.R);
            if (m > n)
            {
                // there should only be only zeros past row n
                R.numRows = compact ? n : m;
            }
            else if (n > m && V.numRows != m)
            {
                DMatrixSparseCSC tmp = new DMatrixSparseCSC(m, n, 0);
                CommonOps_DSCC.extractRows(R, 0, m, tmp);
                R.set(tmp);
            }
            return(R);
        }
        //@Override
        public DMatrixSparseCSC getQ(DMatrixSparseCSC Q, bool compact)
        {
            if (Q == null)
            {
                Q = new DMatrixSparseCSC(1, 1, 0);
            }

            if (compact)
            {
                Q.reshape(V.numRows, n, 0);
            }
            else
            {
                Q.reshape(V.numRows, m, 0);
            }
            DMatrixSparseCSC I = CommonOps_DSCC.identity(V.numRows, Q.numCols);

            for (int i = V.numCols - 1; i >= 0; i--)
            {
                QrHelperFunctions_DSCC.rank1UpdateMultR(V, i, beta[i], I, Q, gwork, gx);
                I.set(Q);
            }

            // Apply P transpose to Q
            CommonOps_DSCC.permutationInverse(structure.pinv, structureP, V.numRows);
            CommonOps_DSCC.permuteRowInv(structureP, Q, I);

            // Remove fictitious rows
            if (V.numRows > m)
            {
                CommonOps_DSCC.extractRows(I, 0, m, Q);
            }
            else
            {
                Q.set(I);
            }

            return(Q);
        }