Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -428,34 +428,31 @@ function Base.isapprox(
)
end

function constant(
f::Union{ScalarAffineFunction,ScalarQuadraticFunction},
T::DataType,
)
function constant(f::Union{ScalarAffineFunction,ScalarQuadraticFunction}, ::Any)
return constant(f)
end
function constant(
f::Union{VectorAffineFunction,VectorQuadraticFunction},
T::DataType,
)

function constant(f::Union{VectorAffineFunction,VectorQuadraticFunction}, ::Any)
return constant(f)
end

"""
constant(f::SingleVariable, T::DataType)
constant(f::SingleVariable, ::Type{T}) where {T}

The constant term of a `SingleVariable` function is
the zero value of the specified type `T`.
"""
constant(f::SingleVariable, T::DataType) = zero(T)
constant(f::SingleVariable, ::Type{T}) where {T} = zero(T)

"""
constant(f::VectorOfVariables, T::DataType)
constant(f::VectorOfVariables, ::Type{T}) where {T}

The constant term of a `VectorOfVariables` function is a
vector of zero values of the specified type `T`.
"""
constant(f::VectorOfVariables, T::DataType) = zeros(T, length(f.variables))
function constant(f::VectorOfVariables, ::Type{T}) where {T}
return zeros(T, length(f.variables))
end

# isbits type, nothing to copy
Base.copy(func::SingleVariable) = func
Expand Down