Exemple #1
0
void cRUtil::GetListVectSexp(SEXP theSEXP, uint theNum, uint theNElt, uint theDim, double** theVal)
{
SEXP myAux ;
        GetValSexp(theSEXP, theNum, myAux) ;
        for (register uint i = 0 ; i < theNElt ; i++)
                GetVectSexp(myAux, i, theDim, theVal[i]) ;
}
Exemple #2
0
/*
* Get a list of vectors and the name of each of them
*/
void cRUtil::GetListNamedVectSexp(SEXP theSEXP, uint theNum, uint theNElt, char** theNames, cDVector* theVal)
{	SEXP myNames = getAttrib(theSEXP, R_NamesSymbol);
	for (register uint i = 0; i < theNElt; i++)
	{	sprintf(theNames[i], CHAR(STRING_ELT(myNames, i)));
		GetVectSexp(theSEXP, i, theVal[i]);
	}
}
Exemple #3
0
/**
 * Retrieves the emission probabilities which either can be stored as list of vectors
 * or as a list of matrices (time-dependent then).
 *
 * We assume that at least one element has been stored before.
 */
void cRUtil::GetEmissionSexp(SEXP theSEXP, uint theNum, std::vector<cDMatrix> &theList)
{
        SEXP myAux = VECTOR_ELT(theSEXP, theNum) ;

        uint nrow = theList.at(0).mNRow;
        uint ncol = theList.at(0).mNCol;
        uint i,j;

        if (!isVector(myAux))
                return;

        if (!isMatrix(VECTOR_ELT(myAux,0)))
        {
                /* Parameter is a list of vectors, as the first elements is no matrix */
                cDVector vec;
                vec.ReAlloc(ncol);

                for (i=0;i<nrow;i++)
                {
                        GetVectSexp(myAux, i, vec);

                        for (j=0;j<ncol;j++)
                                theList.at(0)[i][j] = vec[j];
                }
        } else
        {
                /* Parameter is a list of matrices */

                for (i=0;i<(uint)length(myAux);i++)
                {
                        if (theList.size() <= i)
                        {
                                cDMatrix *mat = new cDMatrix(nrow,ncol,0.0);
                                theList.push_back(*mat);
                        }
                        GetMatSexp(myAux, i, theList.at(i) );
                }
        }
}