double ParGridFunction::GetValue(int i, const IntegrationPoint &ip, int vdim) const { Array<int> dofs; Vector DofVal, LocVec; int nbr_el_no = i - pfes->GetParMesh()->GetNE(); if (nbr_el_no >= 0) { int fes_vdim = pfes->GetVDim(); pfes->GetFaceNbrElementVDofs(nbr_el_no, dofs); if (fes_vdim > 1) { int s = dofs.Size()/fes_vdim; Array<int> _dofs(&dofs[(vdim-1)*s], s); face_nbr_data.GetSubVector(_dofs, LocVec); DofVal.SetSize(s); } else { face_nbr_data.GetSubVector(dofs, LocVec); DofVal.SetSize(dofs.Size()); } pfes->GetFaceNbrFE(nbr_el_no)->CalcShape(ip, DofVal); } else { fes->GetElementDofs(i, dofs); fes->DofsToVDofs(vdim-1, dofs); DofVal.SetSize(dofs.Size()); const FiniteElement *fe = fes->GetFE(i); MFEM_ASSERT(fe->GetMapType() == FiniteElement::VALUE, "invalid FE map type"); fe->CalcShape(ip, DofVal); GetSubVector(dofs, LocVec); } return (DofVal * LocVec); }
void cDerivative::ComputeCov(cHmm& theHmm, cDMatrix& theCov) { uint myNParam = theHmm.GetNParam() ; //uint* myPlace = new uint[myNParam] ; cDVector myScore(mvNFreeParam) ; cDMatrix myInformation(mvNFreeParam, mvNFreeParam) ; ComputeScoreAndInformation(myScore, myInformation) ; theCov = Inv(myInformation) ; uint myNFreeClass = mvNClass - 1 ; uint /*myFreeIndex, myIndexCour, */mySizeCour ; cDVector myU(mvNFreeParam) ; // initProb myU = 0.0 ; for (uint i = 0 ; i < myNFreeClass ; i++) myU[i] = -1.0 ; theCov = AddOneVariable(theCov, myU) ; mySizeCour = mvNFreeParam + 1 ; // transMat uint myBeg = 0 ; for (uint n = 0 ; n < mvNClass ; n++) { myU.ReAlloc(mySizeCour, 0.0) ; myBeg += myNFreeClass ; for (uint i = myBeg ; i < myBeg+myNFreeClass ; i++) myU[i] = -1.0 ; theCov = AddOneVariable(theCov, myU) ; mySizeCour++ ; } // Distribution theHmm.mDistrParam->ComputeCov(theCov) ; // Sorting //uint myNumParam = theHmm.GetNParam() ; cDVector myParamNum(mvNFreeParam) ; cDVector myNFreeClassVect(myNFreeClass) ; uint myIndCour ; uint myNextInd = mvNFreeParam ; cDVector myResNum ; for (uint j = 0 ; j < mvNFreeParam ; j++) myParamNum[j] = j ; // initProba myIndCour = 0 ; GetSubVector(myParamNum, myIndCour, myNFreeClass, myNFreeClassVect) ; myResNum = cat(myNFreeClassVect, (double)myNextInd) ; myNextInd++ ; // transMat for (uint i = 0 ; i < mvNClass ; i++) { myIndCour += myNFreeClass ; GetSubVector(myParamNum, myIndCour, myNFreeClass, myNFreeClassVect) ; myResNum = cat(myResNum, myNFreeClassVect) ; myResNum = cat(myResNum, (double)myNextInd) ; myNextInd++ ; } // distribution myIndCour += myNFreeClass ; cDVector myParamNumDistr ; GetSubVector(myParamNum, myIndCour, mvNFreeParam-myIndCour, myParamNumDistr) ; cDVector myParamNumDistrAll = theHmm.mDistrParam->GetDistrNumParam(myParamNumDistr, myNextInd) ; myResNum = cat(myResNum, myParamNumDistrAll) ; cDMatrix myCov = theCov ; for (uint i = 0 ; i < myNParam ; i++) for (uint j = 0 ; j < myNParam ; j++) theCov[i][j] = myCov[(int)myResNum[i]][(int)myResNum[j]] ; }