mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-19 04:14:28 +00:00
CodeBeautifier for PSR-12 standard.
This commit is contained in:
@ -5,15 +5,15 @@ namespace DNW\Skills\Numerics;
|
||||
/**
|
||||
* Basic math functions.
|
||||
*
|
||||
* @author Jeff Moser <jeff@moserware.com>
|
||||
* @copyright 2010 Jeff Moser
|
||||
* @author Jeff Moser <jeff@moserware.com>
|
||||
* @copyright 2010 Jeff Moser
|
||||
*/
|
||||
class BasicMath
|
||||
{
|
||||
/**
|
||||
* Squares the input (x^2 = x * x)
|
||||
*
|
||||
* @param number $x Value to square (x)
|
||||
* @param number $x Value to square (x)
|
||||
* @return number The squared value (x^2)
|
||||
*/
|
||||
public static function square($x): float|int
|
||||
@ -24,8 +24,8 @@ class BasicMath
|
||||
/**
|
||||
* Sums the items in $itemsToSum
|
||||
*
|
||||
* @param array $itemsToSum The items to sum,
|
||||
* @param callable $callback The function to apply to each array element before summing.
|
||||
* @param array $itemsToSum The items to sum,
|
||||
* @param callable $callback The function to apply to each array element before summing.
|
||||
* @return number The sum.
|
||||
*/
|
||||
public static function sum(array $itemsToSum, \Closure $callback): float|int
|
||||
|
@ -5,8 +5,8 @@ namespace DNW\Skills\Numerics;
|
||||
/**
|
||||
* Computes Gaussian (bell curve) values.
|
||||
*
|
||||
* @author Jeff Moser <jeff@moserware.com>
|
||||
* @copyright 2010 Jeff Moser
|
||||
* @author Jeff Moser <jeff@moserware.com>
|
||||
* @copyright 2010 Jeff Moser
|
||||
*/
|
||||
class GaussianDistribution implements \Stringable
|
||||
{
|
||||
|
@ -70,12 +70,16 @@ class Matrix
|
||||
$transposeMatrix = [];
|
||||
|
||||
$rowMatrixData = $this->_matrixRowData;
|
||||
for ($currentRowTransposeMatrix = 0;
|
||||
for (
|
||||
$currentRowTransposeMatrix = 0;
|
||||
$currentRowTransposeMatrix < $this->_columnCount;
|
||||
$currentRowTransposeMatrix++) {
|
||||
for ($currentColumnTransposeMatrix = 0;
|
||||
$currentRowTransposeMatrix++
|
||||
) {
|
||||
for (
|
||||
$currentColumnTransposeMatrix = 0;
|
||||
$currentColumnTransposeMatrix < $this->_rowCount;
|
||||
$currentColumnTransposeMatrix++) {
|
||||
$currentColumnTransposeMatrix++
|
||||
) {
|
||||
$transposeMatrix[$currentRowTransposeMatrix][$currentColumnTransposeMatrix] =
|
||||
$rowMatrixData[$currentColumnTransposeMatrix][$currentRowTransposeMatrix];
|
||||
}
|
||||
@ -155,8 +159,12 @@ class Matrix
|
||||
$c = $this->_matrixRowData[1][0];
|
||||
$d = $this->_matrixRowData[1][1];
|
||||
|
||||
return new SquareMatrix($d, -$b,
|
||||
-$c, $a);
|
||||
return new SquareMatrix(
|
||||
$d,
|
||||
-$b,
|
||||
-$c,
|
||||
$a
|
||||
);
|
||||
}
|
||||
|
||||
// The idea is that it's the transpose of the cofactors
|
||||
@ -204,8 +212,8 @@ class Matrix
|
||||
{
|
||||
if (
|
||||
($left->getRowCount() != $right->getRowCount())
|
||||
||
|
||||
($left->getColumnCount() != $right->getColumnCount())
|
||||
|
||||
|| ($left->getColumnCount() != $right->getColumnCount())
|
||||
) {
|
||||
throw new Exception('Matrices must be of the same size');
|
||||
}
|
||||
@ -318,8 +326,10 @@ class Matrix
|
||||
for ($currentRow = 0; $currentRow < $this->_rowCount; $currentRow++) {
|
||||
for ($currentColumn = 0; $currentColumn < $this->_columnCount; $currentColumn++) {
|
||||
$delta =
|
||||
abs($this->_matrixRowData[$currentRow][$currentColumn] -
|
||||
$otherMatrix->getValue($currentRow, $currentColumn));
|
||||
abs(
|
||||
$this->_matrixRowData[$currentRow][$currentColumn] -
|
||||
$otherMatrix->getValue($currentRow, $currentColumn)
|
||||
);
|
||||
|
||||
if ($delta > self::ERROR_TOLERANCE) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user