public static function identity(int $n) : self
    {
        if ($n < 1) {
            throw new InvalidArgumentException('Dimensionality must be'
                . ' greater than 0 on all axes.');
        }

        $a = [];

        for ($i = 0; $i < $n; $i++) {
            $temp = [];

            for ($j = 0; $j < $n; $j++) {
                $temp[] = $i === $j ? 1 : 0;
            }

            $a[] = $temp;
        }

        return self::quick($a);
    }
public static function identity(int $n) : self
    {
        if ($n < 1) {
            throw new InvalidArgumentException('Dimensionality must be'
                . ' greater than 0 on all axes.');
        }

        $a = [];

        for ($i = 0; $i < $n; $i++) {
            $temp = [];

            for ($j = 0; $j < $n; $j++) {
                $temp[] = $i === $j ? 1 : 0;
            }

            $a[] = $temp;
        }

        return self::quick($a);
    }
public static function identity ( int $ n ) : self { if ( $ n < 1 ) { throw new InvalidArgumentException ( 'Dimensionality must be' . ' greater than 0 on all axes.' ) ; } $ a = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ temp = [ ] ; for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { $ temp [ ] = $ i === $ j ? 1 : 0 ; } $ a [ ] = $ temp ; } return self :: quick ( $ a ) ; }
Return an identity matrix with the given dimensions.

@param int $n
@throws \InvalidArgumentException
@return self
Return an identity matrix with the given dimensions .