Beispiel #1
0
// make the list, aggregate the seconds in the subtask:
TimeSheetInfoList TimeSheetInfo::taskWithSubTasks( const CharmDataModel* dataModel, int segments, TaskId id,
    const SecondsMap& secondsMap,
    TimeSheetInfo* addTo )
{
    TimeSheetInfoList result;
    TimeSheetInfoList children;

    TimeSheetInfo myInformation(segments);
    const TaskTreeItem& item = dataModel->taskTreeItem( id );
    // real task or virtual root item
    Q_ASSERT( item.task().isValid() || id == 0 );

    if ( id != 0 ) {
        // add totals for task itself:
        if ( secondsMap.contains( id ) ) {
            myInformation.seconds = secondsMap.value(id);
        }
        // add name and id:
        myInformation.taskId = item.task().id();
        myInformation.taskName = item.task().name();

        if ( addTo != 0 ) {
            myInformation.indentation = addTo->indentation + 1;
        }
        myInformation.taskId = id;
    } else {
        myInformation.indentation = -1;
    }

    TaskIdList childIds = item.childIds();
    // sort by task id
    qSort( childIds );
    // recursively add those to myself:
    Q_FOREACH ( const TaskId i, childIds ) {
        children << taskWithSubTasks( dataModel, segments, i, secondsMap, &myInformation );
    }
Beispiel #2
0
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]] ;
}