本文整理汇总了C++中CFactor::GetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactor::GetMatrix方法的具体用法?C++ CFactor::GetMatrix怎么用?C++ CFactor::GetMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFactor
的用法示例。
在下文中一共展示了CFactor::GetMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DimOfModel
int CBICLearningEngine::DimOfModel(const CStaticGraphicalModel *pModel)
{
/*
compute dimension of the model in (d)
it using in BIC criterion:
BIC = LogLic - 0.5*d*log(N)
*/
int nParam = pModel->GetNumberOfFactors();
CFactor *param = NULL;
int dimOfModel = 0;
int dim = 1;
CMatrix<float> *matrix;;
for (int i = 0; i < nParam; i++)
{
dim = 1;
param = pModel->GetFactor(i);
switch (param->GetFactorType())
{
case ftCPD:
{
switch (param->GetDistributionType())
{
case dtTabular:
{
matrix = param->GetMatrix(matTable);
int size;
const int *ranges;
static_cast<CNumericDenseMatrix<float>*>(matrix)->
GetRanges(&size, &ranges);
for(int j=0; j < size - 1; j++)
{
dim *= ranges[j];
}
dim *= ranges[size-1]-1;
break;
}//case dtTabular
case dtGaussian:
{
PNL_THROW(CNotImplemented,"Gaussian")
break;
}//case dtGaussian
case dtCondGaussian:
{
PNL_THROW(CNotImplemented,"CondGaussian")
break;
}//case dtCondGaussian
default:
{
PNL_THROW(CBadConst,"distribution type")
break;
}
}//swith(param->GetFactorType)
break;
}//end case ftCPD
case ftPotential:
{
PNL_THROW(CNotImplemented,"Factor")
break;
}
default:
{
PNL_THROW(CBadConst,"FactorType")
break;
}
}//end switch(param->GetFactor)
dimOfModel += dim;
}//end for(i)
return dimOfModel;
}
示例2: CreateMeanAndCovMatrixForNode
void CSoftMaxCPD::CreateMeanAndCovMatrixForNode(int Node, const CEvidence* pEvidence,
const CBNet *pBNet, floatVector &Mean,
C2DNumericDenseMatrix<float>**CovContParents) const
{
int i, j, k;
int *multiindex = new int [2];
intVector contParents;
pBNet->GetContinuousParents(Node, &contParents);
intVector lineSizes;
lineSizes.assign(2, contParents.size());
floatVector zerodata;
zerodata.assign(contParents.size()*contParents.size(), 0.0f);
*CovContParents =
C2DNumericDenseMatrix<float>::Create( &lineSizes.front(), &zerodata.front() );
for (i = 0; i < contParents.size(); i++ )
{
for (j = 0; j < contParents.size(); j++ )
{
multiindex[0] = i;
multiindex[1] = j;
(*CovContParents)->SetElementByIndexes(0.0f, multiindex);
}
}
intVector pObsNodes;
pConstValueVector pObsValues;
pConstNodeTypeVector pNodeTypes;
pEvidence->GetObsNodesWithValues(&pObsNodes, &pObsValues, &pNodeTypes);
Mean.resize(0);
for ( i = 0; i < contParents.size(); i++)
{
int CurNode = contParents[i];
CFactor *param;
param = pBNet->GetFactor(CurNode);
intVector parentOut;
intVector DiscrParents;
pBNet->GetDiscreteParents(CurNode, &DiscrParents);
int *parentComb = new int [DiscrParents.size()];
for ( j = 0; j < DiscrParents.size(); j++)
{
for ( k = 0; k < pObsNodes.size(); k++)
{
if (DiscrParents[j] == pObsNodes[k])
{
parentComb[j] = pObsValues[k]->GetInt();
break;
}
}
}
const float *data;
int datasize;
static_cast<CDenseMatrix<float>*>(param->GetMatrix(matMean, -1, parentComb))->
GetRawData(&datasize, &data);
Mean.push_back(data[0]);
static_cast<CDenseMatrix<float>*>(param->GetMatrix(matCovariance, -1, parentComb))->
GetRawData(&datasize, &data);
multiindex[0] = i;
multiindex[1] = i;
(*CovContParents)->SetElementByIndexes(data[0], multiindex);
delete [] parentComb;
}
delete [] multiindex;
}