mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-15 02:24:28 +00:00
29 lines
794 B
PHP
29 lines
794 B
PHP
<?php
|
|
|
|
namespace DNW\Skills\Numerics;
|
|
|
|
class DiagonalMatrix extends Matrix
|
|
{
|
|
/**
|
|
* @param float[] $diagonalValues
|
|
*/
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|