Skip to content

Commit

Permalink
Merge pull request #58 from COBREXA/sew-quad-bug
Browse files Browse the repository at this point in the history
Finish up TODOs in QV types
  • Loading branch information
stelmo authored Dec 23, 2024
2 parents 5773631 + 4920f59 commit 3960208
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/quadratic_value.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ Base.zero(::Type{QuadraticValueT{T}}) where {T} =
QuadraticValueT{T}(idxs = Tuple{Int,Int}[], weights = T[])
Base.:+(a::Real, b::QuadraticValueT{T}) where {T} = QuadraticValueT{T}(a) + b
Base.:+(a::QuadraticValueT{T}, b::Real) where {T} = a + QuadraticValueT{T}(b)
Base.:+(a::LinearValueT, b::QuadraticValueT) = QuadraticValue(a) + b # TODO
Base.:+(a::QuadraticValueT, b::LinearValueT) = a + QuadraticValue(b) # TODO
Base.:+(a::LinearValueT, b::QuadraticValueT) = QuadraticValueT(a) + b
Base.:+(a::QuadraticValueT, b::LinearValueT) = a + QuadraticValueT(b)
Base.:-(a::QuadraticValueT) = -1 * a
Base.:-(a::Real, b::QuadraticValueT{T}) where {T} = QuadraticValueT{T}(a) - b
Base.:-(a::QuadraticValueT{T}, b::Real) where {T} = a - QuadraticValueT{T}(b)
Base.:-(a::LinearValueT, b::QuadraticValueT) = QuadraticValue(a) - b # TODO
Base.:-(a::QuadraticValueT, b::LinearValueT) = a - QuadraticValue(b) # TODO
Base.:-(a::LinearValueT, b::QuadraticValueT) = QuadraticValueT(a) - b
Base.:-(a::QuadraticValueT, b::LinearValueT) = a - QuadraticValueT(b)
Base.:-(a::QuadraticValueT, b::QuadraticValueT) = a + (-1 * b)
Base.:*(a::Real, b::QuadraticValueT) = b * a
Base.:*(a::QuadraticValueT, b::Real) =
QuadraticValue(idxs = a.idxs, weights = b .* a.weights)
QuadraticValueT(idxs = a.idxs, weights = b .* a.weights)
Base.:/(a::QuadraticValueT, b::Real) =
QuadraticValue(idxs = a.idxs, weights = a.weights ./ b)

Expand Down

0 comments on commit 3960208

Please sign in to comment.