protected function multiplyScalar($scalar) : self
    {
        if (!is_int($scalar) and !is_float($scalar)) {
            throw new InvalidArgumentException('Scalar must be an integer'
                . ' or float, ' . gettype($scalar) . ' found.');
        }

        if ($scalar == 0) {
            return self::zeros(...$this->shape());
        }

        $b = [];

        foreach ($this->a as $row) {
            $temp = [];

            foreach ($row as $value) {
                $temp[] = $value * $scalar;
            }

            $b[] = $temp;
        }

        return self::quick($b);
    }
protected function multiplyScalar($scalar) : self
    {
        if (!is_int($scalar) and !is_float($scalar)) {
            throw new InvalidArgumentException('Scalar must be an integer'
                . ' or float, ' . gettype($scalar) . ' found.');
        }

        if ($scalar == 0) {
            return self::zeros(...$this->shape());
        }

        $b = [];

        foreach ($this->a as $row) {
            $temp = [];

            foreach ($row as $value) {
                $temp[] = $value * $scalar;
            }

            $b[] = $temp;
        }

        return self::quick($b);
    }
protected function multiplyScalar ( $ scalar ) : self { if ( ! is_int ( $ scalar ) and ! is_float ( $ scalar ) ) { throw new InvalidArgumentException ( 'Scalar must be an integer' . ' or float, ' . gettype ( $ scalar ) . ' found.' ) ; } if ( $ scalar == 0 ) { return self :: zeros ( ... $ this -> shape ( ) ) ; } $ b = [ ] ; foreach ( $ this -> a as $ row ) { $ temp = [ ] ; foreach ( $ row as $ value ) { $ temp [ ] = $ value * $ scalar ; } $ b [ ] = $ temp ; } return self :: quick ( $ b ) ; }
Multiply this matrix by a scalar.

@param mixed $scalar
@throws \InvalidArgumentException
@return self
Multiply this matrix by a scalar .