-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Fix various bugs with Real-valued Hermitian matrices #3805
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3805 +/- ##
=======================================
Coverage 97.90% 97.90%
=======================================
Files 44 44
Lines 6010 6020 +10
=======================================
+ Hits 5884 5894 +10
Misses 126 126 ☔ View full report in Codecov by Sentry. |
We now get: julia> using JuMP
julia> using LinearAlgebra
julia> import Hypatia
julia> import Ket
julia> import Random
julia> function dual_test(d)
Random.seed!(1)
ρ = Ket.random_state(Float64, d^2, 1)
model = Model()
@variable(model, σ[1:d^2, 1:d^2] in PSDCone())
@variable(model, λ)
noisy_state = Hermitian(ρ + λ * I(d^2))
@constraint(model, witness_constraint, σ == noisy_state)
@objective(model, Min, λ)
@constraint(model, Ket.partial_transpose(σ, 2, [d, d]) in PSDCone())
set_optimizer(model, Hypatia.Optimizer)
set_silent(model)
optimize!(model)
W = dual(witness_constraint)
return W
end
dual_test (generic function with 1 method)
julia> dual_test(2)
4×4 Symmetric{Float64, Matrix{Float64}}:
-0.119631 0.213316 -0.213316 0.380369
0.213316 -0.380369 -0.119631 0.213316
-0.213316 -0.119631 -0.380369 -0.213316
0.380369 0.213316 -0.213316 -0.119631 |
I'm not fully convinced about this one. You could argue that we should be able to return @blegat should weigh in before we merge. |
My underlying problem is that Julia has both |
@@ -571,3 +569,55 @@ function Base.complex( | |||
) | |||
return r + im * i | |||
end | |||
|
|||
function Base.:+( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment that the fault returns a Matrix
and we overload to return a Hermitian
. This is already done in LinearAlgebra
for subtypes of Real
It might make more sense to return |
Sounds good. |
Closes #3804
Now the dual of #3804 is Hermitian