/* FIXME: Create a more general version of this operation */ SEXP dsCMatrix_to_dgTMatrix(SEXP x) { cholmod_sparse *A = as_cholmod_sparse(x); cholmod_sparse *Afull = cholmod_copy(A, /*stype*/ 0, /*mode*/ 1, &c); cholmod_triplet *At = cholmod_sparse_to_triplet(Afull, &c); if (!A->stype) error("Non-symmetric matrix passed to dsCMatrix_to_dgTMatrix"); Free(A); cholmod_free_sparse(&Afull, &c); return chm_triplet_to_SEXP(At, 1, /*uploT*/ 0, "", GET_SLOT(x, Matrix_DimNamesSym)); }
SEXP Csparse_to_Tsparse(SEXP x, SEXP tri) { CHM_SP chxs = AS_CHM_SP__(x); CHM_TR chxt = cholmod_l_sparse_to_triplet(chxs, &c); int tr = asLogical(tri); int Rkind = (chxs->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0; R_CheckStack(); return chm_triplet_to_SEXP(chxt, 1, tr ? ((*uplo_P(x) == 'U') ? 1 : -1) : 0, Rkind, tr ? diag_P(x) : "", GET_SLOT(x, Matrix_DimNamesSym)); }
/* FIXME: Create a more general version of this operation: also for lsC, (dsR?),.. * e.g. make compressed_to_dgTMatrix() in ./dgCMatrix.c work for dsC */ SEXP dsCMatrix_to_dgTMatrix(SEXP x) { CHM_SP A = AS_CHM_SP__(x); CHM_SP Afull = cholmod_l_copy(A, /*stype*/ 0, /*mode*/ 1, &c); CHM_TR At = cholmod_l_sparse_to_triplet(Afull, &c); R_CheckStack(); if (!A->stype) error("Non-symmetric matrix passed to dsCMatrix_to_dgTMatrix"); cholmod_l_free_sparse(&Afull, &c); return chm_triplet_to_SEXP(At, 1, /*uploT*/ 0, /*Rkind*/ 0, "", GET_SLOT(x, Matrix_DimNamesSym)); }