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

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

Constructor
public __construct ( array $A )
$A array
    public function __construct(array $A)
    {
        $this->A = $A;
        $this->m = count($A);
        $this->n = $this->m > 0 ? count($A[0]) : 0;
        if ($this->m !== $this->n) {
            throw new Exception\MatrixException('Not a square matrix; row count and column count differ');
        }
    }

Usage Example

 public function __construct(array $A)
 {
     $n = count($A);
     $m = count($A[0]);
     if ($m !== $n) {
         throw new Exception\BadDataException("n must equal m for square Function Matrix. n = {$n}, m = {$m}");
     }
     parent::__construct($A);
 }