7 for (
int n = 0; n < pots.rows; n++)
13 DGM_ASSERT_MSG(start_node + pots.rows <=
getNumNodes(),
"The given ranges exceed the number of nodes(%zu)",
getNumNodes());
17 int rangeSize = size / (concurrency::GetProcessorCount() * 10);
18 rangeSize = MAX(1, rangeSize);
20 concurrency::parallel_for(0, size, rangeSize, [start_node, size, rangeSize, &pots,
this](
int i) {
21 for (
int j = 0; (j < rangeSize) && (i + j < size); j++)
22 setNode(start_node + i + j, pots.row(i + j).t());
25 for (
int n = 0; n < pots.rows; n++)
26 setNode(start_node + n, pots.row(n).t());
31 if (!num_nodes) num_nodes =
getNumNodes() - start_node;
34 DGM_ASSERT_MSG(start_node + num_nodes <=
getNumNodes(),
"The given ranges exceed the number of nodes(%zu)",
getNumNodes());
36 if (pots.empty() || pots.cols !=
m_nStates || pots.rows != num_nodes)
37 pots = Mat(static_cast<int>(num_nodes),
m_nStates, CV_32FC1);
39 transpose(pots, pots);
43 int rangeSize = size / (concurrency::GetProcessorCount() * 10);
44 rangeSize = MAX(1, rangeSize);
46 concurrency::parallel_for(0, size, rangeSize, [start_node, size, rangeSize, &pots,
this](
int i) {
48 for (
int j = 0; (j < rangeSize) && (i + j < size); j++)
49 getNode(start_node + i + j, lvalue_cast(pots.col(i + j)));
52 for (
int n = 0; n < pots.cols; n++)
53 getNode(start_node + n, lvalue_cast(pots.col(n)));
55 transpose(pots, pots);
virtual void setNode(size_t node, const Mat &pot)=0
Sets or changes the potential of node.
virtual size_t addNode(const Mat &pot=EmptyMat)=0
Adds an additional node (with specified potentional)
virtual size_t getNumNodes(void) const =0
Returns the number of nodes in the graph.
virtual void addNodes(const Mat &pots)
Adds the graph nodes with potentials.
virtual void getNode(size_t node, Mat &pot) const =0
Returns the node potential.
virtual void getNodes(size_t start_node, size_t num_nodes, Mat &pots) const
Returns the node potentials.
byte m_nStates
The number of states (classes)
virtual void setNodes(size_t start_node, const Mat &pots)
Fills the graph nodes with new potentials.