mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-18 20:04:28 +00:00
Cleanup in src/, adding namespaces, removing php closing tag and general code cleanup
This commit is contained in:
23
src/Numerics/DiagonalMatrix.php
Normal file
23
src/Numerics/DiagonalMatrix.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace Moserware\Skills\Numerics;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user