Files
trueskill/src/Numerics/SquareMatrix.php

25 lines
601 B
PHP
Raw Normal View History

2022-07-05 15:55:47 +02:00
<?php
declare(strict_types=1);
2022-07-05 15:55:47 +02:00
namespace DNW\Skills\Numerics;
final class SquareMatrix extends Matrix
{
2023-08-02 13:19:35 +00:00
public function __construct(float|int ...$allValues)
{
2024-02-15 09:08:01 +00:00
$size = (int)sqrt(count($allValues));
2022-07-05 15:55:47 +02:00
$matrixData = [];
$allValuesIndex = 0;
2024-02-21 13:48:37 +00:00
for ($currentRow = 0; $currentRow < $size; ++$currentRow) {
for ($currentColumn = 0; $currentColumn < $size; ++$currentColumn) {
$matrixData[$currentRow][$currentColumn] = $allValues[$allValuesIndex++];
}
}
2024-02-15 09:08:01 +00:00
parent::__construct($size, $size, $matrixData);
}
2022-07-05 15:55:47 +02:00
}