Files
trueskill/src/Numerics/DiagonalMatrix.php

23 lines
743 B
PHP
Raw Normal View History

<?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);
}
}
}
}
}