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) ; } }
/*! * \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") ; }
void cAr::RegArchParamToVector(cDVector& theDestVect, uint theIndex) { uint mySize = mvAr.GetSize() ; if (theDestVect.GetSize() < mySize + theIndex) throw cRegArchError("wrong size") ; mvAr.SetSubVectorWithThis(theDestVect, theIndex) ; }
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) ; }
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 ; }
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) ; }
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) ; }
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()) ; }
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 ; }
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()) ; }
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 ; }
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) ; }
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] ; }
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) ; }
/*! * \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 ; } }
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() ; } }
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") ; } }
void cConstCondVar::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex) { if (1 + theIndex > theSrcVect.GetSize()) throw cRegArchError("wrong size") ; mvCste = theSrcVect[theIndex] ; }
void cConstCondVar::RegArchParamToVector(cDVector& theDestVect, uint theIndex) { if (theDestVect.GetSize() < theIndex - 1) throw cRegArchError("wrong size") ; theDestVect[theIndex] = mvCste; }
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] ; }
void cConst::RegArchParamToVector(cDVector& theDestVect, uint theIndex) { if ((int)theDestVect.GetSize() + 1 < (int)theIndex) throw cError("Wrong size") ; theDestVect[theIndex] = mvConst ; }
void cConst::VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex) { if (1 + theIndex > theSrcVect.GetSize()) throw cError("Wrong size") ; mvConst = theSrcVect[theIndex] ; }
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] ; }
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") ; }