MathPHP\LinearAlgebra\DiagonalMatrix::__construct PHP Метод

__construct() публичный Метод

The elements of this array are placed on the diagonal of a square matrix.
public __construct ( array $D )
$D array
    public function __construct(array $D)
    {
        $this->m = count($D);
        $this->n = $this->m;
        $A = [];
        for ($i = 0; $i < $this->m; $i++) {
            for ($j = 0; $j < $this->m; $j++) {
                if ($i == $j) {
                    $A[$i][$j] = $D[$i];
                } else {
                    $A[$i][$j] = 0;
                }
            }
        }
        $this->A = $A;
    }