1 #include "InferExact.h" 2 #include "GraphPairwise.h" 11 vec_byte_t state(nNodes);
17 float Z = std::accumulate(P.cbegin(), P.cend(), 0.0f);
20 for (
size_t n = 0; n < nNodes; n++)
25 for (
size_t n = 0; n < nNodes; n++) {
27 nPot.at<
float>(state[n], 0) += p / Z;
virtual void setNode(size_t node, const Mat &pot)=0
Sets or changes the potential of node.
byte getNumStates(void) const
Returns number of states (classes)
vec_float_t calculatePotentials(void) const
Calculates potentials for all possible configurations.
virtual size_t getNumNodes(void) const =0
Returns the number of nodes in the graph.
void incState(vec_byte_t &state) const
Increases the state by one, i.e. switches the state array to the consequent configuration.
virtual void getNode(size_t node, Mat &pot) const =0
Returns the node potential.
CGraph & getGraph(void) const
Returns the reference to the graph.
void setState(vec_byte_t &state, qword configuration) const
Sets the state according to the configuration index configuration.
virtual void infer(unsigned int nIt=0)
Exact inference.