src/MatrixMath.php
public static function mulScalar(Matrix $matrix, float $scalar) : Matrix {
        $type   = get_class($matrix);
        $result = new $type();

        for ($i=0;$i<$type::ROWS;$i++) {
            for ($j=0;$j<$type::COLUMNS;$j++) {
                $result[$i][$j] = $matrix[$i][$j] * $scalar;
            }
        }

        return $result;
    }
public static function mulScalar(Matrix $matrix, float $scalar) : Matrix {
        $type   = get_class($matrix);
        $result = new $type();

        for ($i=0;$i<$type::ROWS;$i++) {
            for ($j=0;$j<$type::COLUMNS;$j++) {
                $result[$i][$j] = $matrix[$i][$j] * $scalar;
            }
        }

        return $result;
    }
public static function mulScalar ( Matrix $ matrix , float $ scalar ) : Matrix { $ type = get_class ( $ matrix ) ; $ result = new $ type ( ) ; for ( $ i = 0 ; $ i < $ type :: ROWS ; $ i ++ ) { for ( $ j = 0 ; $ j < $ type :: COLUMNS ; $ j ++ ) { $ result [ $ i ] [ $ j ] = $ matrix [ $ i ] [ $ j ] * $ scalar ; } } return $ result ; }
Matrix scalar multiplication.

@param Matrix $matrix
@param float $scalar
@return Matrix
Matrix scalar multiplication .