-
Notifications
You must be signed in to change notification settings - Fork 8
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
Errors in complex algebra with Symmetric and Hermitian #264
Comments
The issue is that we shouldn't wrap in julia> B = MA._mult_upper(im, m)
2×2 Matrix{GenericAffExpr{ComplexF64, VariableRef}}:
real(m[1,1]) im real(m[1,2]) im - imag(m[1,2])
real(m[1,2]) im + imag(m[1,2]) real(m[2,2]) im
julia> h = Hermitian(B, :U)
2×2 Hermitian{GenericAffExpr{ComplexF64, VariableRef}, Matrix{GenericAffExpr{ComplexF64, VariableRef}}}:
-real(m[1,1]) im real(m[1,2]) im - imag(m[1,2])
-real(m[1,2]) im - imag(m[1,2]) -real(m[2,2]) im
julia> h.data
2×2 Matrix{GenericAffExpr{ComplexF64, VariableRef}}:
real(m[1,1]) im real(m[1,2]) im - imag(m[1,2])
real(m[1,2]) im + imag(m[1,2]) real(m[2,2]) im |
That's weird. Shouldn't 2×2 Hermitian{GenericAffExpr{ComplexF64, VariableRef}, Matrix{GenericAffExpr{ComplexF64, VariableRef}}}:
0.0 real(m[1,2]) im - imag(m[1,2])
-real(m[1,2]) im - imag(m[1,2]) 0.0 |
Yes, looks like another bug, it calls |
With #265, we now get: julia> using JuMP
julia> model = Model();
julia> @variable(model, m[1:2,1:2] in HermitianPSDCone());
julia> im*m
2×2 Matrix{GenericAffExpr{ComplexF64, VariableRef}}:
real(m[1,1]) im real(m[1,2]) im - imag(m[1,2])
real(m[1,2]) im + imag(m[1,2]) real(m[2,2]) im |
Wait, please, don't close the issue! What about getting a new dispatch so that a Hermitian matrix multiplied by a real variable stays Hermitian? It is the only reason I was even testing this stuff. |
I'll open a separate issue. |
Great, thanks. |
The algebra with complex numbers and Symmetric or Hermitian matrices doesn't work as it should. First of all, multiplying a complex number by a Hermitian matrix gives an incorrect result wrapped in Hermitian:
Also, if I create a real variable and multiply it by a Symmetric or Hermitian matrix, I get the correct result, but it's no longer wrapped in Symmetric or Hermitian:
(Of course, Symmetric matrices multiplied by complex variables should still be Symmetric, but I don't think this will ever matter.)
The text was updated successfully, but these errors were encountered: