Description
The eltype if -Q
where Q
is a matrix is expected not to change which is incorrect when the eltype is Bool
or VariableRef
:
julia> B = ones(Bool, 1, 1)
1×1 Array{Bool,2}:
true
julia> -Symmetric(B)
ERROR: InexactError: Bool(-1)
Stacktrace:
[1] Type at ./float.jl:73 [inlined]
[2] convert at ./number.jl:7 [inlined]
[3] setindex! at ./array.jl:767 [inlined]
[4] copyto!(::IndexLinear, ::Array{Bool,2}, ::IndexLinear, ::Array{Int64,2}) at ./abstractarray.jl:753
[5] copyto! at ./abstractarray.jl:745 [inlined]
[6] Type at ./array.jl:482 [inlined]
[7] convert at ./array.jl:474 [inlined]
[8] Type at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/symmetric.jl:10 [inlined]
[9] -(::Symmetric{Bool,Array{Bool,2}}) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/symmetric.jl:394
[10] top-level scope at none:0
julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
julia> @variable(model, Q[1:2, 1:2], Symmetric)
2×2 Symmetric{VariableRef,Array{VariableRef,2}}:
Q[1,1] Q[1,2]
Q[1,2] Q[2,2]
julia> -Q
ERROR: MethodError: Cannot `convert` an object of type GenericAffExpr{Float64,VariableRef} to an object of type VariableRef
Closest candidates are:
convert(::Type{T}, ::T) where T at essentials.jl:154
VariableRef(::Any, ::Any) at /home/blegat/.julia/dev/JuMP/src/variables.jl:99
Stacktrace:
[1] setindex!(::Array{VariableRef,2}, ::GenericAffExpr{Float64,VariableRef}, ::Int64) at ./array.jl:767
[2] copyto! at ./abstractarray.jl:753 [inlined]
[3] copyto! at ./abstractarray.jl:745 [inlined]
[4] Array{VariableRef,2}(::Array{GenericAffExpr{Float64,VariableRef},2}) at ./array.jl:482
[5] convert at ./array.jl:474 [inlined]
[6] Type at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/symmetric.jl:10 [inlined]
[7] -(::Symmetric{VariableRef,Array{VariableRef,2}}) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/symmetric.jl:394
[8] top-level scope at none:0
Metadata
Metadata
Assignees
Labels
No labels