Cleanup in src/, adding namespaces, removing php closing tag and general code cleanup

This commit is contained in:
Alexander Liljengård
2016-05-24 14:10:39 +02:00
parent 9f97eb1653
commit 5694a2fb30
64 changed files with 891 additions and 1328 deletions

View File

@ -1,8 +1,4 @@
<?php
namespace Moserware\Skills\FactorGraphs;
require_once(dirname(__FILE__) . "/Factor.php");
<?php namespace Moserware\Skills\FactorGraphs;
/**
* Helper class for computing the factor graph's normalization constant.
@ -14,8 +10,7 @@ class FactorList
public function getLogNormalization()
{
$list = &$this->_list;
foreach($list as &$currentFactor)
{
foreach ($list as &$currentFactor) {
$currentFactor->resetMarginals();
}
@ -23,22 +18,19 @@ class FactorList
$listCount = count($this->_list);
for ($i = 0; $i < $listCount; $i++)
{
for ($i = 0; $i < $listCount; $i++) {
$f = $this->_list[$i];
$numberOfMessages = $f->getNumberOfMessages();
for ($j = 0; $j < $numberOfMessages; $j++)
{
for ($j = 0; $j < $numberOfMessages; $j++) {
$sumLogZ += $f->sendMessageIndex($j);
}
}
$sumLogS = 0;
foreach($list as &$currentFactor)
{
foreach ($list as &$currentFactor) {
$sumLogS = $sumLogS + $currentFactor->getLogNormalization();
}
@ -55,6 +47,4 @@ class FactorList
$this->_list[] = $factor;
return $factor;
}
}
?>
}