Skip to content

Commit

Permalink
Fix zeroing of sparsevector when coefficient is MOI.ScalarAffineFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed May 28, 2024
1 parent 5bd4ae5 commit aa48b2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/coefficients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ end

# general mutable API
# why here?
MA.operate!(::typeof(zero), v::SparseVector) = (v .= 0; v)
function MA.operate!(::typeof(zero), v::SparseVector)
empty!(SparseArrays.nonzeroinds(v))
empty!(SparseArrays.nonzeros(v))
return v
end

Base.zero(X::AbstractCoefficients) = MA.operate!(zero, similar(X))
Base.:-(X::AbstractCoefficients) = MA.operate_to!(__prealloc(X, -1, *), -, X)
Expand Down

0 comments on commit aa48b2c

Please sign in to comment.