Skip to content

Commit

Permalink
Refactor matmul code with mul!
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 20, 2019
1 parent 62ef2a1 commit d25cced
Show file tree
Hide file tree
Showing 3 changed files with 199 additions and 150 deletions.
7 changes: 7 additions & 0 deletions src/aff_expr.jl
Expand Up @@ -293,6 +293,13 @@ end

Base.convert(::Type{GenericAffExpr{T,V}}, v::V) where {T,V} = GenericAffExpr(zero(T), v => one(T))
Base.convert(::Type{GenericAffExpr{T,V}}, v::Real) where {T,V} = GenericAffExpr{T,V}(convert(T, v))
# Used in `JuMP._mul!`.
function Base.convert(::Type{T}, aff::GenericAffExpr{T}) where T
if !isempty(aff.terms)
throw(InexactError(:convert, T, aff))
end
return convert(T, aff.constant)
end

# Alias for (Float64, VariableRef), the specific GenericAffExpr used by JuMP
const AffExpr = GenericAffExpr{Float64,VariableRef}
Expand Down

0 comments on commit d25cced

Please sign in to comment.