More type work.

This commit is contained in:
2023-08-02 10:10:57 +00:00
parent a60187a3fd
commit 5c7471963c
14 changed files with 43 additions and 38 deletions

View File

@ -4,7 +4,7 @@ namespace DNW\Skills\Numerics;
class IdentityMatrix extends DiagonalMatrix
{
public function __construct($rows)
public function __construct(int $rows)
{
parent::__construct(array_fill(0, $rows, 1));
}

View File

@ -8,7 +8,7 @@ class Matrix
{
public const ERROR_TOLERANCE = 0.0000000001;
public function __construct(private int $rowCount = 0, private int $columnCount = 0, private $matrixRowData = null)
public function __construct(private int $rowCount = 0, private int $columnCount = 0, private array $matrixRowData = array())
{
}
@ -28,12 +28,10 @@ class Matrix
return $result;
}
public static function fromRowsColumns(...$args): Matrix
public static function fromRowsColumns(int $rows, int $cols, float|int ...$args): Matrix
{
$rows = $args[0];
$cols = $args[1];
$result = new Matrix($rows, $cols);
$currentIndex = 2;
$currentIndex = 0;
for ($currentRow = 0; $currentRow < $rows; $currentRow++) {
for ($currentCol = 0; $currentCol < $cols; $currentCol++) {