mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-19 04:14:28 +00:00
rector: codingStyle
This commit is contained in:
@ -15,8 +15,8 @@ class DiagonalMatrix extends Matrix
|
||||
|
||||
parent::__construct($diagonalCount, $diagonalCount);
|
||||
|
||||
for ($currentRow = 0; $currentRow < $diagonalCount; $currentRow++) {
|
||||
for ($currentCol = 0; $currentCol < $diagonalCount; $currentCol++) {
|
||||
for ($currentRow = 0; $currentRow < $diagonalCount; ++$currentRow) {
|
||||
for ($currentCol = 0; $currentCol < $diagonalCount; ++$currentCol) {
|
||||
if ($currentRow === $currentCol) {
|
||||
$this->setValue($currentRow, $currentCol, $diagonalValues[$currentRow]);
|
||||
} else {
|
||||
|
@ -15,10 +15,11 @@ class GaussianDistribution implements \Stringable
|
||||
//sqrt(2*pi)
|
||||
//from https://www.wolframalpha.com/input?i=sqrt%282*pi%29
|
||||
private const M_SQRT_2_PI = 2.5066282746310005024157652848110452530069867406099383166299235763;
|
||||
|
||||
|
||||
//log(sqrt(2*pi))
|
||||
//From https://www.wolframalpha.com/input?i=log%28sqrt%282*pi%29%29
|
||||
private const M_LOG_SQRT_2_PI = 0.9189385332046727417803297364056176398613974736377834128171515404;
|
||||
|
||||
// precision and precisionMean are used because they make multiplying and dividing simpler
|
||||
// (the the accompanying math paper for more details)
|
||||
private float $precision;
|
||||
@ -209,7 +210,7 @@ class GaussianDistribution implements \Stringable
|
||||
$d = 0.0;
|
||||
$dd = 0.0;
|
||||
|
||||
for ($j = $ncof - 1; $j > 0; $j--) {
|
||||
for ($j = $ncof - 1; $j > 0; --$j) {
|
||||
$tmp = $d;
|
||||
$d = $ty * $d - $dd + $coefficients[$j];
|
||||
$dd = $tmp;
|
||||
@ -227,6 +228,7 @@ class GaussianDistribution implements \Stringable
|
||||
if ($p >= 2.0) {
|
||||
return -100;
|
||||
}
|
||||
|
||||
if ($p <= 0.0) {
|
||||
return 100;
|
||||
}
|
||||
@ -235,7 +237,7 @@ class GaussianDistribution implements \Stringable
|
||||
$t = sqrt(-2 * log($pp / 2.0)); // Initial guess
|
||||
$x = -M_SQRT1_2 * ((2.30753 + $t * 0.27061) / (1.0 + $t * (0.99229 + $t * 0.04481)) - $t);
|
||||
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
for ($j = 0; $j < 2; ++$j) {
|
||||
$err = GaussianDistribution::errorFunctionCumulativeTo($x) - $pp;
|
||||
$x += $err / (M_2_SQRTPI * exp(-BasicMath::square($x)) - $x * $err); // Halley
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ class Matrix
|
||||
$data = [];
|
||||
$result = new Matrix($rows, $columns, $data);
|
||||
|
||||
for ($currentColumn = 0; $currentColumn < $columns; $currentColumn++) {
|
||||
for ($currentColumn = 0; $currentColumn < $columns; ++$currentColumn) {
|
||||
$currentColumnData = $columnValues[$currentColumn];
|
||||
|
||||
for ($currentRow = 0; $currentRow < $rows; $currentRow++) {
|
||||
for ($currentRow = 0; $currentRow < $rows; ++$currentRow) {
|
||||
$result->setValue($currentRow, $currentColumn, $currentColumnData[$currentRow]);
|
||||
}
|
||||
}
|
||||
@ -41,8 +41,8 @@ class Matrix
|
||||
$result = new Matrix($rows, $cols);
|
||||
$currentIndex = 0;
|
||||
|
||||
for ($currentRow = 0; $currentRow < $rows; $currentRow++) {
|
||||
for ($currentCol = 0; $currentCol < $cols; $currentCol++) {
|
||||
for ($currentRow = 0; $currentRow < $rows; ++$currentRow) {
|
||||
for ($currentCol = 0; $currentCol < $cols; ++$currentCol) {
|
||||
$result->setValue($currentRow, $currentCol, $args[$currentIndex++]);
|
||||
}
|
||||
}
|
||||
@ -76,8 +76,8 @@ class Matrix
|
||||
$transposeMatrix = [];
|
||||
|
||||
$rowMatrixData = $this->matrixRowData;
|
||||
for ($currentRowTransposeMatrix = 0; $currentRowTransposeMatrix < $this->columnCount; $currentRowTransposeMatrix++) {
|
||||
for ($currentColumnTransposeMatrix = 0; $currentColumnTransposeMatrix < $this->rowCount; $currentColumnTransposeMatrix++) {
|
||||
for ($currentRowTransposeMatrix = 0; $currentRowTransposeMatrix < $this->columnCount; ++$currentRowTransposeMatrix) {
|
||||
for ($currentColumnTransposeMatrix = 0; $currentColumnTransposeMatrix < $this->rowCount; ++$currentColumnTransposeMatrix) {
|
||||
$transposeMatrix[$currentRowTransposeMatrix][$currentColumnTransposeMatrix] =
|
||||
$rowMatrixData[$currentColumnTransposeMatrix][$currentRowTransposeMatrix];
|
||||
}
|
||||
@ -126,7 +126,7 @@ class Matrix
|
||||
$result = 0.0;
|
||||
|
||||
// I expand along the first row
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; $currentColumn++) {
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
|
||||
$firstRowColValue = $this->matrixRowData[0][$currentColumn];
|
||||
$cofactor = $this->getCofactor(0, $currentColumn);
|
||||
$itemToAdd = $firstRowColValue * $cofactor;
|
||||
@ -168,8 +168,8 @@ class Matrix
|
||||
// The idea is that it's the transpose of the cofactors
|
||||
$result = [];
|
||||
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; $currentColumn++) {
|
||||
for ($currentRow = 0; $currentRow < $this->rowCount; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
|
||||
for ($currentRow = 0; $currentRow < $this->rowCount; ++$currentRow) {
|
||||
$result[$currentColumn][$currentRow] = $this->getCofactor($currentRow, $currentColumn);
|
||||
}
|
||||
}
|
||||
@ -197,8 +197,8 @@ class Matrix
|
||||
$columns = $matrix->getColumnCount();
|
||||
$newValues = [];
|
||||
|
||||
for ($currentRow = 0; $currentRow < $rows; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $columns; $currentColumn++) {
|
||||
for ($currentRow = 0; $currentRow < $rows; ++$currentRow) {
|
||||
for ($currentColumn = 0; $currentColumn < $columns; ++$currentColumn) {
|
||||
$newValues[$currentRow][$currentColumn] = $scalarValue * $matrix->getValue($currentRow, $currentColumn);
|
||||
}
|
||||
}
|
||||
@ -216,8 +216,8 @@ class Matrix
|
||||
|
||||
$resultMatrix = [];
|
||||
|
||||
for ($currentRow = 0; $currentRow < $left->getRowCount(); $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $right->getColumnCount(); $currentColumn++) {
|
||||
for ($currentRow = 0; $currentRow < $left->getRowCount(); ++$currentRow) {
|
||||
for ($currentColumn = 0; $currentColumn < $right->getColumnCount(); ++$currentColumn) {
|
||||
$resultMatrix[$currentRow][$currentColumn] =
|
||||
$left->getValue($currentRow, $currentColumn)
|
||||
+
|
||||
@ -242,11 +242,11 @@ class Matrix
|
||||
|
||||
$resultMatrix = [];
|
||||
|
||||
for ($currentRow = 0; $currentRow < $resultRows; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $resultColumns; $currentColumn++) {
|
||||
for ($currentRow = 0; $currentRow < $resultRows; ++$currentRow) {
|
||||
for ($currentColumn = 0; $currentColumn < $resultColumns; ++$currentColumn) {
|
||||
$productValue = 0;
|
||||
|
||||
for ($vectorIndex = 0; $vectorIndex < $left->getColumnCount(); $vectorIndex++) {
|
||||
for ($vectorIndex = 0; $vectorIndex < $left->getColumnCount(); ++$vectorIndex) {
|
||||
$leftValue = $left->getValue($currentRow, $vectorIndex);
|
||||
$rightValue = $right->getValue($vectorIndex, $currentColumn);
|
||||
$vectorIndexProduct = $leftValue * $rightValue;
|
||||
@ -269,24 +269,24 @@ class Matrix
|
||||
|
||||
$actualRow = 0;
|
||||
|
||||
for ($currentRow = 0; $currentRow < $this->rowCount; $currentRow++) {
|
||||
for ($currentRow = 0; $currentRow < $this->rowCount; ++$currentRow) {
|
||||
if ($currentRow == $rowToRemove) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$actualCol = 0;
|
||||
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; $currentColumn++) {
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
|
||||
if ($currentColumn == $columnToRemove) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$actualRow][$actualCol] = $this->matrixRowData[$currentRow][$currentColumn];
|
||||
|
||||
$actualCol++;
|
||||
++$actualCol;
|
||||
}
|
||||
|
||||
$actualRow++;
|
||||
++$actualRow;
|
||||
}
|
||||
|
||||
return new Matrix($this->rowCount - 1, $this->columnCount - 1, $result);
|
||||
@ -312,8 +312,8 @@ class Matrix
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for ($currentRow = 0; $currentRow < $this->rowCount; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; $currentColumn++) {
|
||||
for ($currentRow = 0; $currentRow < $this->rowCount; ++$currentRow) {
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
|
||||
$delta =
|
||||
abs(
|
||||
$this->matrixRowData[$currentRow][$currentColumn] -
|
||||
|
@ -13,8 +13,8 @@ class SquareMatrix extends Matrix
|
||||
$matrixData = [];
|
||||
$allValuesIndex = 0;
|
||||
|
||||
for ($currentRow = 0; $currentRow < $size; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $size; $currentColumn++) {
|
||||
for ($currentRow = 0; $currentRow < $size; ++$currentRow) {
|
||||
for ($currentColumn = 0; $currentColumn < $size; ++$currentColumn) {
|
||||
$matrixData[$currentRow][$currentColumn] = $allValues[$allValuesIndex++];
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class Vector extends Matrix
|
||||
foreach ($vectorValues as $currentVectorValue) {
|
||||
$columnValues[] = [$currentVectorValue];
|
||||
}
|
||||
|
||||
parent::__construct(count($vectorValues), 1, $columnValues);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user