-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Hermitian, ishermitian now check diagonals #10672
Conversation
Hermitian(A::AbstractMatrix, uplo::Symbol=:U) = (chksquare(A);Hermitian{eltype(A),typeof(A)}(A, char_uplo(uplo))) | ||
function Hermitian(A::AbstractMatrix, uplo::Symbol=:U) | ||
chksquare(A) | ||
all(isreal(diag(A))) || throw(ArgumentError( |
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.
I think we should do this without allocation.
Can anyone shed light on the 32-bit build failure?
|
Build failure seems unrelated. |
Hermitian, ishermitian now check diagonals
This is causing intermittent failures, the tolerances look a little too tight |
Could you point me to a failure? |
Bump. Any suggestions for mitigating these? |
I wrote a simple PR but I got an inscrutable error. |
I think we should revert because it gives some annoying exceptions this are often unwanted. We don't check that a matrix is symmetric in cc: @bnels |
Ignoring the diagonal sounds like a pretty bad idea - the constructors here should verify the invariants that their types represent. |
No. The point is that the user already knows that the matrix has the property or that the matrix should be interpreted in that way. Similarly to allowing julia> LowerTriangular(randn(3,3))
3x3 LowerTriangular{Float64,Array{Float64,2}}:
-0.193406 0.0 0.0
-0.225881 -1.29177 0.0
1.83933 1.77965 -1.24135 |
Unlike |
It's not necessary to mutate anything. The methods for julia> cholfact(fill(complex(1.0,1.0), 1, 1))
Base.LinAlg.Cholesky{Complex{Float64},Array{Complex{Float64},2}} with factor:
1x1 UpperTriangular{Complex{Float64},Array{Complex{Float64},2}}:
1.0+0.0im |
Every single method then. getindex and everything else you might ever call on a |
No. It's not easy to verify without a lot of unnecesary exceptions. One of the main reasons to use I dont' think ingoring imaginary parts in the diagonal will be that demanding. Making the very small change to |
|
There might be a few other places in |
Methods that use in any way other than getindex, or leave alone without checking, diagonal elements for any abstract supertype of Hermitian would need to be made aware of this special case, or have a more specific method written for Hermitian. I'm anticipating there will be quite a few places in base that would get this wrong. This is the kind of thing where we start needing type-based coverage stats. I'm more referring to users sending their data to C libraries outside of base. The proposal is to store undefined data that we intentionally want to be meaningless inline within the same diagonal scalar values. This could be documented and tested thoroughly for corner cases, and left up to the user to manually zero the imaginary components for this ccall case, but this isn't something we've done any other places to my knowledge. |
Fix #10671
I also had to fix some tests which had incorrectly neglected to check the diagonals.