-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
issymmetric
with rtol, atol
#737
Comments
Would this check |
cc @stevengj |
I think that (Using an approximate-equality test by default in things like Cholesky routines is a tricker question, which seems like it would require some careful analysis. See also the discussion in #182.) |
issymmetric
with rtol, atolissymmetric
with rtol, atol
I wrote a package to try to approach this in a systematic way. You can have a default notion of closeness for a particular method. But, there is a uniform interface allowing they user to specify what they want. In particular, for |
What's the advantage of calling |
It should be about 2x faster. |
@stevengjl, In this case, the former reduces to the latter. The sequence of calls is issymmetric(A, Approx())
ishermitian(A, Approx())
isapprox(Approx(), A, adjoint(A))
# and the final call above goes to the following method.
Base.isapprox(a::Union{EachApprox, Approx}, x, y) = isapprox(x, y; pairs(a.kw)...) ( An advantage is that you can drop in m = rand(1000,1000);
A = m + m' .* (1 + rand() * 1e-12);
julia> @btime IsApprox.issymmetric($A, EachApprox(atol=1e-15))
8.555 ns (0 allocations: 0 bytes)
false
julia> @btime IsApprox.issymmetric($A, Approx(atol=1e-15))
3.638 ms (2 allocations: 7.63 MiB)
false ( The idea is to do this uniformly for everything. For example m = [9.914830625828892e-11 4.473996666408231e-11 3.066184129948095e-11;
9.914231937308404e-12 7.07270051593276e-11 6.487445728681865e-11;
9.587109787642197e-11 6.520784660158512e-11 1.2903560723094866e-11]
@test iszero(m, Approx(atol=2e-10)) # in norm
@test ! iszero(m, Approx(atol=1e-10))
@test iszero(m, EachApprox(atol=2e-10)) # element-wise
@test iszero(m, EachApprox(atol=1e-10))
@test ! iszero(m) # exact
@test ! iszero(m, Equal()) # exact What I really want to avoid is that each of the many predicates is treated separately to add support for closeness in norm and or elementwise, (and as I recently added, up to a global phase) in a different, and ad hoc, way. I wrote this package after seeing exactly this happen in a number of quantum information packages. |
Duplicate of #558. (No need to discuss this in two places as is happening now). |
Hi,
would be great if one could pass arguments to
issymmetric
, which specifies the absolut and/or relative tolerance between the upper and lower triangle, similar toisapprox(x,y; atol=..., rtol=...)
.Thanks!
The text was updated successfully, but these errors were encountered: