mirror of
https://github.com/furyfire/trueskill.git
synced 2025-06-27 23:21:32 +00:00
Cleanup in src/, adding namespaces, removing php closing tag and general code cleanup
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
namespace Moserware\Numerics;
|
||||
<?php namespace Moserware\Skills\Numerics;
|
||||
|
||||
class Matrix
|
||||
{
|
||||
@ -369,76 +368,4 @@ class Matrix
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class Vector extends Matrix
|
||||
{
|
||||
public function __construct(array $vectorValues)
|
||||
{
|
||||
$columnValues = array();
|
||||
foreach($vectorValues as $currentVectorValue)
|
||||
{
|
||||
$columnValues[] = array($currentVectorValue);
|
||||
}
|
||||
parent::__construct(count($vectorValues), 1, $columnValues);
|
||||
}
|
||||
}
|
||||
|
||||
class SquareMatrix extends Matrix
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$allValues = \func_get_args();
|
||||
$rows = (int) sqrt(count($allValues));
|
||||
$cols = $rows;
|
||||
|
||||
$matrixData = array();
|
||||
$allValuesIndex = 0;
|
||||
|
||||
for ($currentRow = 0; $currentRow < $rows; $currentRow++)
|
||||
{
|
||||
for ($currentColumn = 0; $currentColumn < $cols; $currentColumn++)
|
||||
{
|
||||
$matrixData[$currentRow][$currentColumn] = $allValues[$allValuesIndex++];
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($rows, $cols, $matrixData);
|
||||
}
|
||||
}
|
||||
|
||||
class DiagonalMatrix extends Matrix
|
||||
{
|
||||
public function __construct(array $diagonalValues)
|
||||
{
|
||||
$diagonalCount = count($diagonalValues);
|
||||
$rowCount = $diagonalCount;
|
||||
$colCount = $rowCount;
|
||||
|
||||
parent::__construct($rowCount, $colCount);
|
||||
|
||||
for($currentRow = 0; $currentRow < $rowCount; $currentRow++)
|
||||
{
|
||||
for($currentCol = 0; $currentCol < $colCount; $currentCol++)
|
||||
{
|
||||
if($currentRow == $currentCol)
|
||||
{
|
||||
$this->setValue($currentRow, $currentCol, $diagonalValues[$currentRow]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setValue($currentRow, $currentCol, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IdentityMatrix extends DiagonalMatrix
|
||||
{
|
||||
public function __construct($rows)
|
||||
{
|
||||
parent::__construct(\array_fill(0, $rows, 1));
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
Reference in New Issue
Block a user