Ejemplo n.º 1
0
void cRUtil::SetListValSexp(cDVector& theVal, SEXP &theSEXP)
{	mvNbProtect++ ;
	PROTECT(theSEXP = allocVector(VECSXP, theVal.GetSize())) ;
	for (register uint i = 0 ; i < theVal.GetSize() ; i++)
	{	SEXP myAux ;
		SetValSexp(theVal[i], myAux) ;
		SET_VECTOR_ELT(theSEXP, i, myAux) ;
	}
}
Ejemplo n.º 2
0
	/*!
	 * \fn void cConst::ReAlloc(const cDVector& theVectParam, const uint theNumParam)
	 * \param const cDVector& theVectParam: the constant value is in theVectParam[0]
	 * \param const uint theNumParam: not used for cConst class
	 * \details Here, mvConst = theVectParam[0]
	 */
	void cConst::ReAlloc(const cDVector& theVectParam, const uint theNumParam)
	{
		if (theVectParam.GetSize() > 0)
			mvConst = theVectParam[0] ;
		else
			throw cError("Size of 'theVectParam' must be > 0") ;
	}
Ejemplo n.º 3
0
void cAr::RegArchParamToVector(cDVector& theDestVect, uint theIndex)
{
uint mySize = mvAr.GetSize() ;
	if (theDestVect.GetSize() < mySize + theIndex)
		throw cRegArchError("wrong size") ;
	mvAr.SetSubVectorWithThis(theDestVect, theIndex) ;
}
Ejemplo n.º 4
0
void cAr::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex)
{
uint mySize = theSrcVect.GetSize() ;
	if (mvAr.GetSize() + theIndex > mySize)
		throw cRegArchError("wrong size") ;
	mvAr.SetThisWithSubVector(theSrcVect, theIndex) ;
}
Ejemplo n.º 5
0
cDMatrix Transpose(const cDVector& theVect)
{
uint myNCol = theVect.GetSize() ;
cDMatrix myTmpMat(1, myNCol) ;
    for (uint i = 0 ; i < myNCol ; i++)
                myTmpMat[0][i] = theVect[i] ;
    return myTmpMat ;
}
Ejemplo n.º 6
0
		void cArch::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex)
		{
			uint mySize = theSrcVect.GetSize() ;
			if (GetNParam() + theIndex > mySize)
				throw cError("Wrong size") ;
			mvConst = theSrcVect[theIndex] ;
			mvArch.SetThisWithSubVector(theSrcVect, theIndex+1) ;
		}
Ejemplo n.º 7
0
		void cArch::RegArchParamToVector(cDVector& theDestVect, uint theIndex)
		{
			uint mySize = GetNParam() ;
			if (theDestVect.GetSize() < mySize + theIndex)
				throw cError("Wrong size") ;
			theDestVect[theIndex] = mvConst ;
			mvArch.SetSubVectorWithThis(theDestVect, theIndex+1) ;
		}
Ejemplo n.º 8
0
void cTarch::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex)
{
uint mySize = theSrcVect.GetSize() ;
	if (GetNParam() + theIndex > mySize)
		throw cRegArchError("wrong size") ;
	mvCste = theSrcVect[theIndex] ;
	mvArchPos.SetThisWithSubVector(theSrcVect, theIndex+1) ;
	mvArchNeg.SetThisWithSubVector(theSrcVect, theIndex+1+mvArchPos.GetSize()) ;
}
Ejemplo n.º 9
0
cDMatrix Diag(cDVector& theVect)
{
uint mySize = theVect.GetSize() ;
cDMatrix myTempMatrix(mySize, mySize) ;
        for (register uint i = 0 ; i <mySize ; i++)
                myTempMatrix[i][i] = theVect[i] ;

        return myTempMatrix ;
}
Ejemplo n.º 10
0
void cTarch::RegArchParamToVector(cDVector& theDestVect, uint theIndex)
{
uint mySize = GetNParam() ;
	if (theDestVect.GetSize() < mySize + theIndex)
		throw cRegArchError("wrong size") ;
	theDestVect[theIndex] = mvCste ;
	mvArchPos.SetSubVectorWithThis(theDestVect, theIndex+1) ;
	mvArchNeg.SetSubVectorWithThis(theDestVect, theIndex+1+mvArchPos.GetSize()) ;

}
Ejemplo n.º 11
0
static cDMatrix MatMult(const cDVector& theVect, const cDMatrix& theMat)
{
uint myNRow = theVect.GetSize() ;
uint myNCol = theMat.GetNCols() ;
cDMatrix myTmpMat(myNRow, myNCol) ;
    
    for (uint i = 0 ; i < myNCol ; i++)
    {   for (uint j = 0 ; j < myNRow ; j++)
            myTmpMat[i][j] = theVect[i] * theMat[0][j] ;
    }
    return myTmpMat ;
}
Ejemplo n.º 12
0
void cAparch::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex)
{uint	mySize = theSrcVect.GetSize(),
		myIndex = theIndex ;
	if (GetNParam() + theIndex > mySize)
		throw cRegArchError("wrong size") ;
	mvCste = theSrcVect[myIndex++] ;
	mvDelta = theSrcVect[myIndex++] ;
	mvArch.SetThisWithSubVector(theSrcVect,myIndex) ;
	myIndex += mvArch.GetSize() ;
	mvGamma.SetThisWithSubVector(theSrcVect,myIndex) ;
	myIndex += mvGamma.GetSize() ;
	mvGarch.SetThisWithSubVector(theSrcVect,myIndex) ;
}
Ejemplo n.º 13
0
void AddColRow(const cDVector& theColRow, cDMatrix& theMat) 
{
uint myNRow = theMat.GetNRows() ;
uint myNCol = theMat.GetNCols() ;
uint mySize = theColRow.GetSize() ;
	if ( (myNRow != myNCol) || (myNRow + 1 != mySize) )
		throw cOTError("Wrong sizes in AddColRow") ;
cDMatrix mySrcMatrix = theMat ;
	theMat.ReAlloc(mySize, mySize) ;
	SetSubMatrix(mySrcMatrix, 0, 0, theMat) ;
	for (register uint i = 0 ; i < mySize  ; i++)
		theMat[i][mySize-1] = theMat[mySize-1][i] = theColRow[i] ;
}
Ejemplo n.º 14
0
void cAparch::RegArchParamToVector(cDVector& theDestVect, uint theIndex)
{
uint	mySize = GetNParam(),
		myIndex = theIndex		;
	
	if (theDestVect.GetSize() < mySize + theIndex)
		throw cRegArchError("wrong size") ;
	theDestVect[myIndex++] = mvCste ;
	theDestVect[myIndex++] = mvDelta ;
	mvArch.SetSubVectorWithThis(theDestVect, myIndex) ;
	myIndex += mvArch.GetSize() ;
	mvGamma.SetSubVectorWithThis(theDestVect, myIndex) ;
	myIndex += mvGamma.GetSize() ;
	mvGarch.SetSubVectorWithThis(theDestVect, myIndex) ;
}
Ejemplo n.º 15
0
		/*!
		 * \fn void cArch::Set(const cDVector& theVectParam, const uint theNumParam)
		 * \brief fill the parameters vector
		 * \param const cDVector& theVectParam: the vector of values
		 * \param const uint theNumParam: =0, mvConst; =1, mvArch
		 * \details mvArch = theVectParam or mvConst = theVectParam[0]
		 */
		void cArch::Set(const cDVector& theVectParam, const uint theNumParam)
		{	switch (theNumParam)
			{	case 0 :
				if (theVectParam.GetSize() > 0)
					mvConst = theVectParam[0] ;
				else
					throw cError("cArch::Set - Size of theVectParam must be > 0") ;
				break ;
				case 1 :
				mvArch = theVectParam ;
				break ;
				default:
				throw cError("cArch::Set - theNumParam must be in 0, 1") ;
				break ;
			}
		}
Ejemplo n.º 16
0
void cRegArchValue::ReAllocValue(cDVector& theYt)
{
int mySize = (int)theYt.GetSize() ;
	ClearMatrix(mXt) ;
	if (mySize > 0)
	{	mYt = theYt ;
		mMt.ReAlloc(mySize) ;
		mHt.ReAlloc(mySize) ;
		mUt.ReAlloc(mySize) ;
		mEpst.ReAlloc(mySize) ;
	}
	else
	{	mYt.Delete() ;
		mMt.Delete() ;
		mHt.Delete() ;
		mUt.Delete() ;
		mEpst.Delete() ;
	}
}
Ejemplo n.º 17
0
void cRegArchValue::ReAllocValue(cDVector& theYt, cDMatrix& theXt) // Xt T rows, p columns
{
uint mySize = theYt.GetSize() ;
	if ( (mySize > 0)&& (mySize == theXt.GetNRow()) )
	{	mYt = theYt ;
		mXt = theXt ;
		mMt.ReAlloc(mySize) ;
		mHt.ReAlloc(mySize) ;
		mUt.ReAlloc(mySize) ;
		mEpst.ReAlloc(mySize) ;
	}
	else
	{	mYt.Delete();
		ClearMatrix(mXt) ;
		mMt.Delete() ;
		mHt.Delete() ;
		mUt.Delete() ;
		mEpst.Delete() ;
		throw cRegArchError("incompatibility beetwen Yt and Xt") ;
	}
}
Ejemplo n.º 18
0
void cConstCondVar::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex)
{
	if (1 + theIndex > theSrcVect.GetSize())
		throw cRegArchError("wrong size") ;
	mvCste = theSrcVect[theIndex] ;
}
Ejemplo n.º 19
0
void cConstCondVar::RegArchParamToVector(cDVector& theDestVect, uint theIndex) 
{
	if (theDestVect.GetSize() < theIndex - 1)
		throw cRegArchError("wrong size") ;
	theDestVect[theIndex] = mvCste;
}
Ejemplo n.º 20
0
void cRUtil::GetVectSexp(SEXP theSEXP, uint theNum, cDVector& theVal)
{
SEXP myAux = VECTOR_ELT(theSEXP, theNum) ;
	for (register uint i = 0 ; i < theVal.GetSize() ; i++)
		theVal[i] = REAL(myAux)[i] ;
}
Ejemplo n.º 21
0
	void cConst::RegArchParamToVector(cDVector& theDestVect, uint theIndex)
	{
		if ((int)theDestVect.GetSize() + 1 < (int)theIndex)
			throw cError("Wrong size") ;
		theDestVect[theIndex] = mvConst ;
	}
Ejemplo n.º 22
0
	void cConst::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex)
	{
		if (1 + theIndex > theSrcVect.GetSize())
			throw cError("Wrong size") ;
		mvConst = theSrcVect[theIndex] ;
	}
Ejemplo n.º 23
0
void cRUtil::SetVectSexp(cDVector& theVect, SEXP &theSEXP)
{	mvNbProtect++ ;
	PROTECT(theSEXP=allocVector(REALSXP, theVect.GetSize())) ;
	for (register uint i = 0 ; i < theVect.GetSize() ; i++)
		REAL(theSEXP)[i] = theVect[i] ;
}
Ejemplo n.º 24
0
	void cConst::Set(const cDVector& theVectParam, const uint theNumParam)
	{	if (theVectParam.GetSize() > 0)
			mvConst = theVectParam[0] ;
		else
			throw cError("the size of theVectParam must be > 0") ;
	}