Skip to content

Commit

Permalink
addToExpression(::AffExpr, ::Variable, ::Number)
Browse files Browse the repository at this point in the history
  • Loading branch information
joehuchette committed Aug 16, 2015
1 parent 96c1270 commit 1c38224
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/v0.4/parseExpr_staged.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ function addToExpression{C,V}(aff::GenericAffExpr{C,V},c::Number,x::GenericAffEx
aff
end

# help w/ ambiguity
addToExpression{C,V<:Number}(aff::GenericAffExpr{C,V}, c::Number, x::Number) =
__addToExpression__(aff, c, x)

function addToExpression{C,V}(aff::GenericAffExpr{C,V}, c::V, x::Number)
if x != 0
push!(aff.vars, c)
push!(aff.coeffs, x)
end
aff
end

addToExpression{C,V}(aff::GenericAffExpr{C,V},c::V,x::V) =
GenericQuadExpr{C,V}([c],[x],[one(C)],aff)

Expand Down

0 comments on commit 1c38224

Please sign in to comment.