void omxLISRELExpectation::populateAttr(SEXP algebra) { auto oo = this; ProtectedSEXP RnumStat(Rf_ScalarReal(omxDataDF(oo->data))); Rf_setAttrib(algebra, Rf_install("numStats"), RnumStat); /* omxLISRELExpectation* oro = (omxLISRELExpectation*) (oo->argStruct); omxMatrix* LX = oro->LX; omxMatrix* LY = oro->LY; omxMatrix* BE = oro->BE; omxMatrix* GA = oro->GA; omxMatrix* PH = oro->PH; omxMatrix* PS = oro->PS; omxMatrix* TD = oro->TD; omxMatrix* TE = oro->TE; omxMatrix* TH = oro->TH; omxMatrix* LXPH = oro->LXPH; omxMatrix* GAPH = oro->GAPH; omxMatrix* W = oro->W; omxMatrix* U = oro->U; omxMatrix* I = oro->I; int numIters = oro->numIters; double oned = 1.0, zerod = 0.0; omxRecompute(LX); omxRecompute(LY); */ //This block of code works fine but because I do not use any of it later, it throws a huge block of Rf_warnings about unused variables. // In general, I do not yet understand what this function needs to do. /* omxShallowInverse(numIters, BE, Z, Ax, I ); // Z = (I-A)^-1 if(OMX_DEBUG_ALGEBRA) { mxLog("....DGEMM: %c %c \n %d %d %d \n %f \n %x %d %x %d \n %f %x %d.", *(Z->majority), *(S->majority), (Z->rows), (S->cols), (S->rows), oned, Z->data, (Z->leading), S->data, (S->leading), zerod, Ax->data, (Ax->leading));} // F77_CALL(omxunsafedgemm)(Z->majority, S->majority, &(Z->rows), &(S->cols), &(S->rows), &oned, Z->data, &(Z->leading), S->data, &(S->leading), &zerod, Ax->data, &(Ax->leading)); // X = ZS omxDGEMM(FALSE, FALSE, oned, Z, S, zerod, Ax); if(OMX_DEBUG_ALGEBRA) { mxLog("....DGEMM: %c %c %d %d %d %f %x %d %x %d %f %x %d.", *(Ax->majority), *(Z->minority), (Ax->rows), (Z->rows), (Z->cols), oned, X->data, (X->leading), Z->data, (Z->lagging), zerod, Ax->data, (Ax->leading));} // F77_CALL(omxunsafedgemm)(Ax->majority, Z->minority, &(Ax->rows), &(Z->rows), &(Z->cols), &oned, Ax->data, &(Ax->leading), Z->data, &(Z->leading), &zerod, Ax->data, &(Ax->leading)); omxDGEMM(FALSE, TRUE, oned, Ax, Z, zerod, Ax); // Ax = ZSZ' = Covariance matrix including latent variables SEXP expCovExt; Rf_protect(expCovExt = Rf_allocMatrix(REALSXP, Ax->rows, Ax->cols)); for(int row = 0; row < Ax->rows; row++) for(int col = 0; col < Ax->cols; col++) REAL(expCovExt)[col * Ax->rows + row] = omxMatrixElement(Ax, row, col); setAttrib(algebra, Rf_install("UnfilteredExpCov"), expCovExt); */ }
void omxPopulateNormalAttributes(omxExpectation *ox, SEXP algebra) { if(OMX_DEBUG) { mxLog("Populating Normal Attributes."); } omxNormalExpectation* one = (omxNormalExpectation*) (ox->argStruct); omxMatrix *cov = one->cov; omxMatrix *means = one->means; omxRecompute(cov, NULL); if(means != NULL) omxRecompute(means, NULL); { SEXP expCovExt; ScopedProtect p1(expCovExt, Rf_allocMatrix(REALSXP, cov->rows, cov->cols)); for(int row = 0; row < cov->rows; row++) for(int col = 0; col < cov->cols; col++) REAL(expCovExt)[col * cov->rows + row] = omxMatrixElement(cov, row, col); Rf_setAttrib(algebra, Rf_install("ExpCov"), expCovExt); } if (means != NULL) { SEXP expMeanExt; ScopedProtect p1(expMeanExt, Rf_allocMatrix(REALSXP, means->rows, means->cols)); for(int row = 0; row < means->rows; row++) for(int col = 0; col < means->cols; col++) REAL(expMeanExt)[col * means->rows + row] = omxMatrixElement(means, row, col); Rf_setAttrib(algebra, Rf_install("ExpMean"), expMeanExt); } else { SEXP expMeanExt; ScopedProtect p1(expMeanExt, Rf_allocMatrix(REALSXP, 0, 0)); Rf_setAttrib(algebra, Rf_install("ExpMean"), expMeanExt); } Rf_setAttrib(algebra, Rf_install("numStats"), Rf_ScalarReal(omxDataDF(ox->data))); }