mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-19 12:24:28 +00:00
23 lines
743 B
PHP
23 lines
743 B
PHP
![]() |
<?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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|