void omxFillMatrixFromMxFitFunction(omxMatrix* om, int matrixNumber, SEXP rObj) { om->hasMatrixNumber = TRUE; om->matrixNumber = matrixNumber; ProtectedSEXP fitFunctionClass(STRING_ELT(Rf_getAttrib(rObj, R_ClassSymbol), 0)); const char *fitType = CHAR(fitFunctionClass); omxExpectation *expect = NULL; ProtectedSEXP slotValue(R_do_slot(rObj, Rf_install("expectation"))); if (Rf_length(slotValue) == 1) { int expNumber = Rf_asInteger(slotValue); if(expNumber != NA_INTEGER) { expect = omxExpectationFromIndex(expNumber, om->currentState); } } bool rowLik = Rf_asInteger(R_do_slot(rObj, Rf_install("vector"))); omxFitFunction *ff = omxNewInternalFitFunction(om->currentState, fitType, expect, om, rowLik); ff->rObj = rObj; }
void omxFillMatrixFromMxFitFunction(omxMatrix* om, const char *fitType, int matrixNumber, SEXP rObj) { om->hasMatrixNumber = TRUE; om->matrixNumber = matrixNumber; SEXP slotValue; omxExpectation *expect = NULL; { ScopedProtect p1(slotValue, R_do_slot(rObj, Rf_install("expectation"))); if (Rf_length(slotValue) == 1) { int expNumber = Rf_asInteger(slotValue); if(expNumber != NA_INTEGER) { expect = omxExpectationFromIndex(expNumber, om->currentState); } } } bool rowLik = Rf_asInteger(R_do_slot(rObj, Rf_install("vector"))); omxFitFunction *ff = omxNewInternalFitFunction(om->currentState, fitType, expect, om, rowLik); ff->rObj = rObj; }