-
-
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
RFC: treat small negative λ as 0 for sqrt(::Hermitian) #35057
Conversation
Oh, I guess this doesn't make sense in the case of a matrix Note that this can change the output of |
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.
LGTM except for the test tolerances.
@andreasnoack, I updated the test tolerances some time ago and tests are passing. Good to merge? |
* treat small negative λ as 0 for sqrt(::Hermitian) and log(::Hermitian) * typo * added tests, docs; removed rtol argument for log * don't ask for rtol so close to eps(Float64)
* treat small negative λ as 0 for sqrt(::Hermitian) and log(::Hermitian) * typo * added tests, docs; removed rtol argument for log * don't ask for rtol so close to eps(Float64)
This PR treats sufficiently small negative eigenvalues as "zero" for the purpose of taking matrix
sqrt
and, as otherwise one gets spurious complex results from semidefinite matrices due to roundoff errors. (See also discourse discussion.)log
It works by adding an
rtol
keyword parameter tosqrt(::Hermitian)
and, specifying a relative tolerance for negative eigenvalues to ignore, which defaults to the same relative tolerance that we use for thelog(::Hermitian)
pinv
function.This is currently just a rough draft to get reactions.To do:rtol
argument forlog
, where semidefinite matrices don't make sense