SEXP Csparse_band(SEXP x, SEXP k1, SEXP k2) { CHM_SP chx = AS_CHM_SP__(x); int Rkind = (chx->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0; CHM_SP ans = cholmod_band(chx, asInteger(k1), asInteger(k2), chx->xtype, &c); R_CheckStack(); return chm_sparse_to_SEXP(ans, 1, 0, Rkind, "", GET_SLOT(x, Matrix_DimNamesSym)); }
double MultivariateFNormalSufficientSparse::trace_WP() const { //solve for Sigma.X=W //cholmod_print_sparse(PW_,"PW",c_); //isolate diagonal cholmod_sparse *tmp = cholmod_band(PW_, 0, 0, 1, c_); //cholmod_print_sparse(tmp,"diag(PW)",c_); double trace=0; if ((tmp->itype != CHOLMOD_INT) || (tmp->xtype != CHOLMOD_REAL)) IMP_THROW("matrix types different from int and double", ModelException); double *x = (double *) tmp->x; for (size_t i=0; i < tmp->nzmax; ++i) trace += x[i]; cholmod_free_sparse(&tmp, c_); IMP_LOG(TERSE, "MVNsparse: trace(WP) = " << trace << std::endl); return trace; }