/** * Sends the ith message to the marginal and returns the log-normalization constant */ public function sendMessageIndex($messageIndex) { Guard::argumentIsValidIndex($messageIndex, count($this->_messages), "messageIndex"); $message =& $this->_messages[$messageIndex]; $variable =& $this->_messageToVariableBinding->getValue($message); return $this->sendMessageVariable($message, $variable); }
public function updateMessageIndex($messageIndex) { $allMessages = $this->getMessages(); $allVariables = $this->getVariables(); Guard::argumentIsValidIndex($messageIndex, count($allMessages), "messageIndex"); $updatedMessages = array(); $updatedVariables = array(); $indicesToUse = $this->_variableIndexOrdersForWeights[$messageIndex]; // The tricky part here is that we have to put the messages and variables in the same // order as the weights. Thankfully, the weights and messages share the same index numbers, // so we just need to make sure they're consistent $allMessagesCount = count($allMessages); for ($i = 0; $i < $allMessagesCount; $i++) { $updatedMessages[] = $allMessages[$indicesToUse[$i]]; $updatedVariables[] = $allVariables[$indicesToUse[$i]]; } return $this->updateHelper($this->_weights[$messageIndex], $this->_weightsSquared[$messageIndex], $updatedMessages, $updatedVariables); }