本文整理汇总了C++中Assignment::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Assignment::clear方法的具体用法?C++ Assignment::clear怎么用?C++ Assignment::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assignment
的用法示例。
在下文中一共展示了Assignment::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mexFunction
//.........这里部分代码省略.........
delete[] local;
local = 0;
// read the factor-potentials
int fac_nd = mxGetNumberOfDimensions(prhs[2]);
const int* fac_dim = mxGetDimensions(prhs[2]);
if (fac_nd != 2 || fac_dim[0]*fac_dim[1] != num_factors || !mxIsCell(prhs[2])) {
mexErrMsgTxt("factor-potentials must be a cell array in size 1x(num_factors), each cell {i} is a column vector in length (num_values(i))");
}
for (int i=0; i<num_factors; i++) {
mxArray* facPot_i = mxGetCell(prhs[2],i);
int i_nd = mxGetNumberOfDimensions(facPot_i);
const int* i_dim = mxGetDimensions(facPot_i);
if (i_nd != 2 || i_dim[0]*i_dim[1] != reg_mrf->V[i]) {
mexErrMsgTxt("each cell {i} in the factor-potentials cell-array must be a vector in length (num_values(i))");
}
// get potentials
double* facPotPtr = mxGetPr(facPot_i);
for (int xi=0; xi<reg_mrf->V[i]; xi++) {
reg_mrf->localMat[i][xi] = facPotPtr[xi];
}
}
// calculate the assignment-indices-table
int*** assignInd = new int**[num_factors];
for (int i=0; i<num_factors; i++) {
Region& reg_i = (*factors)[i];
int i_numStates = reg_mrf->V[i];
assignInd[i] = new int*[reg_i.size()];
Assignment assignment;
assignment.clear();
assignment.resize(num_nodes);
for (int n=0; n<reg_i.size(); n++) {
int node = reg_i[n];
assignInd[i][n] = new int[i_numStates];
for (int i_assignInd=0; i_assignInd<i_numStates; i_assignInd++) {
reg_i.indToAssign(i_assignInd, assignment, &(reg_mrf->V[num_factors]));
assignInd[i][n][i_assignInd] = assignment[node];
}
}
}
// read the rest of parameters
int maxIter = (int)(mxGetScalar(prhs[3]));
SumOrMax sumOrMax = (SumOrMax)((int)(mxGetScalar(prhs[4])));
double gbp_alpha = mxGetScalar(prhs[5]);
bool trw = ((int)(mxGetScalar(prhs[6]))) > 0;
double* countingNode = new double[num_nodes];
fillDouble(prhs[7], countingNode, num_nodes);
double* bethe = new double[num_all_regs];
for (int i=0; i<num_factors; i++) {
bethe[i] = 1.0;
}
for (int i=0; i<num_nodes; i++) {
double q = (1.0 - countingNode[i]) / max(1.0, double(reg_mrf->neighbNum(i+num_factors)));
bethe[i+num_factors] = 1.0 / (2.0 - q);
}
delete[] countingNode;