public static function mul(Matrix $matrix, $value) : Matrix {

        if ($value instanceof Matrix) {
            return self::mulMatrix($matrix, $value);
        }

        if (is_numeric($value)) {
            return self::mulScalar($matrix, $value);
        }

        $type = gettype($value);
        throw new InvalidArgumentException("Invalid type. Can not multiply a matrix with {$type}.");
    }