CMNet* CMNet::CreateWithRandomMatrices( const intVecVector& clqs,
                                            CModelDomain* pMD)
{
    CMNet* pMNet = CMNet::Create( clqs, pMD );

    pMNet->AllocFactors();
    int numFactors = pMNet->GetNumberOfFactors();
    int i;
    for( i = 0; i < numFactors; i++ )
    {
        pMNet->AllocFactor( i );
        CFactor* ft = pMNet->GetFactor(i);
        ft->CreateAllNecessaryMatrices();
    }
    
    return pMNet;
}
//create mnet with random matrices
CMRF2* CMRF2::CreateWithRandomMatrices( int numberOfCliques,
                                       const int *cliqueSizes,
                                       const int **cliques,
                                       CModelDomain* pMD)
{
    CMRF2* pMRF2 = CMRF2::Create( numberOfCliques, cliqueSizes, cliques, pMD );
    
    pMRF2->AllocFactors();
    int numFactors = pMRF2->GetNumberOfFactors();
    int i;
    for( i = 0; i < numFactors; i++ )
    {
        pMRF2->AllocFactor( i );
        CFactor* ft = pMRF2->GetFactor(i);
        ft->CreateAllNecessaryMatrices();
    }
    
    return pMRF2;
}