phpOMS/Math/Matrix/IdentityMatrix.php
2019-07-08 19:51:19 +02:00

43 lines
772 B
PHP

<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package phpOMS\Math\Matrix
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\Math\Matrix;
/**
* Identity Matrix
*
* @package phpOMS\Math\Matrix
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class IdentityMatrix extends Matrix
{
/**
* Constructor.
*
* @param int $n Matrix dimension
*
* @since 1.0.0
*/
public function __construct(int $n)
{
parent::__construct($n, $n);
for ($i = 0; $i < $n; ++$i) {
$this->matrix[$i][$i] = 1;
}
}
}