@@ -468,10 +468,35 @@ end
468468# +(::SparseMatrixCSC) is not defined for generic types in Base.
469469Base.:+ (A:: AbstractArray{<:AbstractMutable} ) = A
470470
471+ # `Base.*(::AbstractArray, α)` is only defined if `α isa Number`
472+ # Currently, mutable types are scalar elements (e.g. JuMP expression,
473+ # MOI functions or polynomials) so broadcasting is the right dispatch.
474+ # If this causes issues in the future, e.g., because a user define a non-scalar
475+ # subtype of `AbstractMutable`, we might want to check that
476+ # `ndims` is zero and error otherwise.
477+
471478Base.:* (α:: AbstractMutable , A:: AbstractArray ) = α .* A
472479
473480Base.:* (A:: AbstractArray , α:: AbstractMutable ) = A .* α
474481
482+ function operate_to! (
483+ output:: AbstractArray ,
484+ :: typeof (* ),
485+ v:: AbstractArray ,
486+ α:: Union{Number,AbstractMutable} ,
487+ )
488+ return Base. broadcast! (* , output, v, α)
489+ end
490+
491+ function operate_to! (
492+ output:: AbstractArray ,
493+ :: typeof (* ),
494+ α:: Union{Number,AbstractMutable} ,
495+ v:: AbstractArray ,
496+ )
497+ return Base. broadcast! (* , output, α, v)
498+ end
499+
475500# Needed for Julia v1.0, otherwise, `broadcast(*, α, A)` gives a `Array` and
476501# not a `Symmetric`.
477502
0 commit comments