mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Optimization efforts
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
.vscode
|
||||
.*/
|
||||
vendor
|
||||
.*.cache/
|
||||
*.phar
|
||||
|
@ -4,6 +4,7 @@
|
||||
"runner.php_disable_ini": true,
|
||||
"runner.retry_threshold": 5,
|
||||
"runner.iterations": 10,
|
||||
"storage.xml_storage_path": "output/benchmarking/",
|
||||
"report.outputs": {
|
||||
"build-artifact": {
|
||||
"renderer": "html",
|
||||
@ -11,4 +12,5 @@
|
||||
"title": "Benchmarking"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,11 +15,11 @@ class BasicMath
|
||||
/**
|
||||
* Squares the input (x^2 = x * x)
|
||||
*
|
||||
* @param float $x Value to square (x)
|
||||
* @param $x Value to square (x)
|
||||
*
|
||||
* @return float The squared value (x^2)
|
||||
*/
|
||||
public static function square($x): float
|
||||
public static function square(float $x): float
|
||||
{
|
||||
return $x * $x;
|
||||
}
|
||||
|
@ -12,13 +12,11 @@ class DiagonalMatrix extends Matrix
|
||||
public function __construct(array $diagonalValues)
|
||||
{
|
||||
$diagonalCount = count($diagonalValues);
|
||||
$rowCount = $diagonalCount;
|
||||
$colCount = $rowCount;
|
||||
|
||||
parent::__construct($rowCount, $colCount);
|
||||
parent::__construct($diagonalCount, $diagonalCount);
|
||||
|
||||
for ($currentRow = 0; $currentRow < $rowCount; $currentRow++) {
|
||||
for ($currentCol = 0; $currentCol < $colCount; $currentCol++) {
|
||||
for ($currentRow = 0; $currentRow < $diagonalCount; $currentRow++) {
|
||||
for ($currentCol = 0; $currentCol < $diagonalCount; $currentCol++) {
|
||||
if ($currentRow === $currentCol) {
|
||||
$this->setValue($currentRow, $currentCol, $diagonalValues[$currentRow]);
|
||||
} else {
|
||||
|
@ -8,18 +8,17 @@ class SquareMatrix extends Matrix
|
||||
{
|
||||
public function __construct(float|int ...$allValues)
|
||||
{
|
||||
$rows = (int)sqrt(count($allValues));
|
||||
$cols = $rows;
|
||||
$size = (int)sqrt(count($allValues));
|
||||
|
||||
$matrixData = [];
|
||||
$allValuesIndex = 0;
|
||||
|
||||
for ($currentRow = 0; $currentRow < $rows; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $cols; $currentColumn++) {
|
||||
for ($currentRow = 0; $currentRow < $size; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $size; $currentColumn++) {
|
||||
$matrixData[$currentRow][$currentColumn] = $allValues[$allValuesIndex++];
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($rows, $cols, $matrixData);
|
||||
parent::__construct($size, $size, $matrixData);
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,6 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
}
|
||||
|
||||
$newPrecision = 1.0 / $inverseOfNewPrecisionSum;
|
||||
$anotherNewPrecision = 1.0 / $anotherInverseOfNewPrecisionSum;
|
||||
|
||||
$newPrecisionMean = $newPrecision * $weightedMeanSum;
|
||||
|
||||
|
Reference in New Issue
Block a user