Skip to content

Commit

Permalink
fix param casting for hhvm compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed May 2, 2016
1 parent 3fd5abf commit 56114d9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Phpml/Clustering/KMeans/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getDistanceWith(self $point, $precise = true)
$distance += $difference * $difference;
}

return $precise ? sqrt($distance) : $distance;
return $precise ? sqrt((float)$distance) : $distance;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Phpml/Math/Distance/Euclidean.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function distance(array $a, array $b): float
$distance += pow($a[$i] - $b[$i], 2);
}

return sqrt($distance);
return sqrt((float)$distance);
}
}
4 changes: 2 additions & 2 deletions src/Phpml/Math/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function calculateDeterminant()
for ($j = 0; $j < $this->columns; ++$j) {
$subMatrix = $this->crossOut(0, $j);
$minor = $this->matrix[0][$j] * $subMatrix->getDeterminant();
$determinant += fmod($j, 2) == 0 ? $minor : -$minor;
$determinant += fmod((float)$j, 2.0) == 0 ? $minor : -$minor;
}
}

Expand Down Expand Up @@ -236,7 +236,7 @@ public function inverse()
for ($i = 0; $i < $this->rows; ++$i) {
for ($j = 0; $j < $this->columns; ++$j) {
$minor = $this->crossOut($i, $j)->getDeterminant();
$newMatrix[$i][$j] = fmod($i + $j, 2) == 0 ? $minor : -$minor;
$newMatrix[$i][$j] = fmod((float)($i + $j), 2.0) == 0 ? $minor : -$minor;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Phpml/Math/Statistic/Correlation.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function pearson(array $x, array $y)
$b2 = $b2 + pow($b, 2);
}

$corr = $axb / sqrt($a2 * $b2);
$corr = $axb / sqrt((float)($a2 * $b2));

return $corr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Phpml/Math/Statistic/StandardDeviation.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public static function population(array $a, $sample = true)
--$n;
}

return sqrt($carry / $n);
return sqrt((float)($carry / $n));
}
}

0 comments on commit 56114d9

Please sign in to comment.