Adding Psalm analysis

This commit is contained in:
2023-08-03 14:26:00 +00:00
parent 3e42b48003
commit 0e1947ca3a
6 changed files with 1975 additions and 18 deletions

View File

@ -11,11 +11,9 @@ class ScheduleLoop extends Schedule
public function visit(int $depth = -1, int $maxDepth = 0): float
{
$totalIterations = 1;
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
while ($delta > $this->maxDelta) {
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
$totalIterations++;
}
return $delta;

View File

@ -13,10 +13,10 @@ class BasicMath
/**
* Squares the input (x^2 = x * x)
*
* @param number $x Value to square (x)
* @return number The squared value (x^2)
* @param float $x Value to square (x)
* @return float The squared value (x^2)
*/
public static function square($x): float|int
public static function square($x): float
{
return $x * $x;
}
@ -26,9 +26,9 @@ class BasicMath
*
* @param mixed[] $itemsToSum The items to sum,
* @param \Closure $callback The function to apply to each array element before summing.
* @return number The sum.
* @return float The sum.
*/
public static function sum(array $itemsToSum, \Closure $callback): float|int
public static function sum(array $itemsToSum, \Closure $callback): float
{
$mappedItems = array_map($callback, $itemsToSum);

View File

@ -25,15 +25,10 @@ class GaussianGreaterThanFactor extends GaussianFactor
public function getLogNormalization(): float
{
/**
* @var Variable[] $vars
*/
$vars = $this->getVariables();
$marginal = $vars[0]->getValue();
/**
* @var Message[] $messages
*/
$messages = $this->getMessages();
$message = $messages[0]->getValue();
$messageFromVariable = GaussianDistribution::divide($marginal, $message);