//--------------------------------------------------------- DMat& chol(DMat& A, bool in_place) //--------------------------------------------------------- { // Given symmetric positive-definite matrix A, // return its Cholesky-factorization for use // later in solving (multiple) linear systems. int M=A.num_rows(), LDA=A.num_rows(), info=0; char uplo = 'U'; if (in_place) { // factorize arg POTRF (uplo, M, A.data(), LDA, info); if (info) { umERROR("chol(A)", "dpotrf reports: info = %d", info); } A.zero_below_diag(); A.set_factmode(FACT_CHOL); // indicate factored state return A; } else { // factorize copy of arg DMat* tmp = new DMat(A, OBJ_temp, "chol(A)"); POTRF (uplo, M, tmp->data(), LDA, info); if (info) { umERROR("chol(A)", "dpotrf reports: info = %d", info); } tmp->zero_below_diag(); tmp->set_factmode(FACT_CHOL); // indicate factored state #if (0) // compare with Matlab tmp->print(g_MSGFile, "chol", "lf", 4, 8); #endif return (*tmp); } }
// Numerical {DMat,IMat} and {DVec,IVec} void dumpDMat(const DMat& M, const char* s) { M.print(g_MSGFile, s, "lf", 4, 8, 51,0,50); }
// simple {DM,IM} and {DV,IV} arrays void dumpDM(const DM& A, const char* s) { DMat M; M.load(A.num_rows(),A.num_cols(), A.data()); M.print(g_MSGFile, s, "lf", 4, 8, 51,0,50); }
// bump up details void dumpDMat2(const DMat& M, const char* s) { M.print(g_MSGFile, s, "E", 2, 10, 101,0,100); }