-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap reshaped vector in LinearAlgebra.Hermitian #3245
Conversation
Codecov ReportBase: 98.08% // Head: 98.08% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #3245 +/- ##
=======================================
Coverage 98.08% 98.08%
=======================================
Files 34 34
Lines 4656 4656
=======================================
Hits 4567 4567
Misses 89 89
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
1ce981e
to
cbabac9
Compare
I think this broke: julia> model = Model(SCS.Optimizer);
julia> E = [@variable(model, [1:d, 1:d] in HermitianPSDCone()) for i in 1:n]
4-element Vector{LinearAlgebra.Hermitian{GenericAffExpr{ComplexF64, VariableRef}, Matrix{GenericAffExpr{ComplexF64, VariableRef}}}}:
[_[1] _[2] + (0.0 + 1.0im) _[11] _[4] + (0.0 + 1.0im) _[12] _[7] + (0.0 + 1.0im) _[14]; _[2] + (0.0 - 1.0im) _[11] _[3] _[5] + (0.0 + 1.0im) _[13] _[8] + (0.0 + 1.0im) _[15]; _[4] + (0.0 - 1.0im) _[12] _[5] + (0.0 - 1.0im) _[13] _[6] _[9] + (0.0 + 1.0im) _[16]; _[7] + (0.0 - 1.0im) _[14] _[8] + (0.0 - 1.0im) _[15] _[9] + (0.0 - 1.0im) _[16] _[10]]
[_[17] _[18] + (0.0 + 1.0im) _[27] _[20] + (0.0 + 1.0im) _[28] _[23] + (0.0 + 1.0im) _[30]; _[18] + (0.0 - 1.0im) _[27] _[19] _[21] + (0.0 + 1.0im) _[29] _[24] + (0.0 + 1.0im) _[31]; _[20] + (0.0 - 1.0im) _[28] _[21] + (0.0 - 1.0im) _[29] _[22] _[25] + (0.0 + 1.0im) _[32]; _[23] + (0.0 - 1.0im) _[30] _[24] + (0.0 - 1.0im) _[31] _[25] + (0.0 - 1.0im) _[32] _[26]]
[_[33] _[34] + (0.0 + 1.0im) _[43] _[36] + (0.0 + 1.0im) _[44] _[39] + (0.0 + 1.0im) _[46]; _[34] + (0.0 - 1.0im) _[43] _[35] _[37] + (0.0 + 1.0im) _[45] _[40] + (0.0 + 1.0im) _[47]; _[36] + (0.0 - 1.0im) _[44] _[37] + (0.0 - 1.0im) _[45] _[38] _[41] + (0.0 + 1.0im) _[48]; _[39] + (0.0 - 1.0im) _[46] _[40] + (0.0 - 1.0im) _[47] _[41] + (0.0 - 1.0im) _[48] _[42]]
[_[49] _[50] + (0.0 + 1.0im) _[59] _[52] + (0.0 + 1.0im) _[60] _[55] + (0.0 + 1.0im) _[62]; _[50] + (0.0 - 1.0im) _[59] _[51] _[53] + (0.0 + 1.0im) _[61] _[56] + (0.0 + 1.0im) _[63]; _[52] + (0.0 - 1.0im) _[60] _[53] + (0.0 - 1.0im) _[61] _[54] _[57] + (0.0 + 1.0im) _[64]; _[55] + (0.0 - 1.0im) _[62] _[56] + (0.0 - 1.0im) _[63] _[57] + (0.0 - 1.0im) _[64] _[58]]
julia> @constraint(model, sum(E) .== LinearAlgebra.I)
ERROR: MethodError: no method matching isreal(::GenericAffExpr{ComplexF64, VariableRef})
Closest candidates are:
isreal(::Complex) at complex.jl:133
isreal(::Missing) at missing.jl:101
isreal(::Union{LinearAlgebra.Hermitian{T, S}, LinearAlgebra.Symmetric{T, S}} where {T, S}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/symmetric.jl:317
...
Stacktrace:
[1] setindex!(A::LinearAlgebra.Hermitian{GenericAffExpr{ComplexF64, VariableRef}, Matrix{GenericAffExpr{ComplexF64, VariableRef}}}, v::GenericAffExpr{ComplexF64, VariableRef}, i::Int64, j::Int64)
@ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/symmetric.jl:232
[2] +(A::LinearAlgebra.Hermitian{GenericAffExpr{ComplexF64, VariableRef}, Matrix{GenericAffExpr{ComplexF64, VariableRef}}}, J::LinearAlgebra.UniformScaling{Int64})
@ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/uniformscaling.jl:219
[3] -
@ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/uniformscaling.jl:160 [inlined]
[4] sub_mul
@ ~/.julia/packages/MutableArithmetics/geMUn/src/MutableArithmetics.jl:38 [inlined]
[5] _broadcast_with_uniform_scaling!
@ ~/.julia/packages/MutableArithmetics/geMUn/src/broadcast.jl:184 [inlined]
[6] broadcast!!(::typeof(MutableArithmetics.sub_mul), ::LinearAlgebra.Hermitian{GenericAffExpr{ComplexF64, VariableRef}, Matrix{GenericAffExpr{ComplexF64, VariableRef}}}, ::LinearAlgebra.UniformScaling{Bool})
@ MutableArithmetics ~/.julia/packages/MutableArithmetics/geMUn/src/broadcast.jl:170
[7] macro expansion
@ ~/.julia/packages/MutableArithmetics/geMUn/src/rewrite.jl:322 [inlined]
[8] macro expansion
@ ~/.julia/dev/JuMP/src/macros.jl:832 [inlined]
[9] top-level scope
@ REPL[20]:1 |
I have a PR with a tutorial and a fix incoming |
This is done for the
Symmetric
counterpart:JuMP.jl/src/sd.jl
Line 151 in 4d64d8d