public function repeat(int $m = 1, int $n = 1) : self
    {
        if ($m < 1 or $n < 1) {
            throw new InvalidArgumentException('Cannot repeat less than 1'
                . ' row or column.');
        }

        $b = $this->a;

        $n -= 1;

        if ($n > 0) {
            foreach ($this->a as $i => $row) {
                for ($j = 0; $j < $n; $j++) {
                    $b[$i] = array_merge($b[$i], $row);
                }
            }
        }

        $c = [];

        for ($i = 0; $i < $m; $i++) {
            $c = array_merge($c, $b);
        }

        return self::quick($c);
    }
public function repeat(int $m = 1, int $n = 1) : self
    {
        if ($m < 1 or $n < 1) {
            throw new InvalidArgumentException('Cannot repeat less than 1'
                . ' row or column.');
        }

        $b = $this->a;

        $n -= 1;

        if ($n > 0) {
            foreach ($this->a as $i => $row) {
                for ($j = 0; $j < $n; $j++) {
                    $b[$i] = array_merge($b[$i], $row);
                }
            }
        }

        $c = [];

        for ($i = 0; $i < $m; $i++) {
            $c = array_merge($c, $b);
        }

        return self::quick($c);
    }
public function repeat ( int $ m = 1 , int $ n = 1 ) : self { if ( $ m < 1 or $ n < 1 ) { throw new InvalidArgumentException ( 'Cannot repeat less than 1' . ' row or column.' ) ; } $ b = $ this -> a ; $ n -= 1 ; if ( $ n > 0 ) { foreach ( $ this -> a as $ i => $ row ) { for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { $ b [ $ i ] = array_merge ( $ b [ $ i ] , $ row ) ; } } } $ c = [ ] ; for ( $ i = 0 ; $ i < $ m ; $ i ++ ) { $ c = array_merge ( $ c , $ b ) ; } return self :: quick ( $ c ) ; }
Repeat the matrix m times along the vertival axes and n times along the
horizontal axes.

@param int $m
@param int $n
@throws \InvalidArgumentException
@return self
Repeat the matrix m times along the vertival axes and n times along the horizontal axes .