-
Notifications
You must be signed in to change notification settings - Fork 10
use Symmetric() to get rid of complex eigen() results #68
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main JuliaLang/julia#68 +/- ##
==========================================
+ Coverage 89.98% 90.56% +0.58%
==========================================
Files 12 12
Lines 529 530 +1
==========================================
+ Hits 476 480 +4
+ Misses 53 50 -3
Continue to review full report at Codecov.
|
src/bounds/ellipsoid.jl
Outdated
axes, axlens = decompose(A) | ||
Ellipsoid(center, A, axes, axlens, _volume(A)) |
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.
Rather than incorporate this here, what if we wrote
decompose(A::AbstractMatrix) = decompose(Symmetric(A))
function decompose(A::Symmetric)
E = eigen(A)
#...
end
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 it makes most sense to have Ellipsoid.A
field to have type of Symmetric
: covariance matrices are symmetric anyway. Unfortunately, it doesn't work because inplace broadcasting with Symmetric
isn't implemented in julia yet - there are several issues, eg https://github.com/JuliaLang/julia/issues/38056. So for now, in this PR, I put the Symmetric
wrapper as "high" in the call stack as possible. Shifting it to the decompose()
level is also possible, of course. Would you prefer that variant?
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.
Thanks for pointing out the mutation issues- I wasn't aware of those. Yes, I prefer to have this at the decompose level, it's not really too different from what you wrote, but I like using the method signatures. If we had a trait system, we could easily switch from decompose(::Symmetric)
to something like decompose(::T) where issymmetric(T)
. FYI, I do have hopes of improving the entire Bounds
interface, since each of these bounds is a sample-able (i.e., implement the Distributions.jl
API for samplers), which would also make them immutable.
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.
Ok, changed.
My point was that it mathematically only makes sense to run decompose
with Symmetric
matrices, same for the Ellipsoid
creation and other related functions. Shouldn't need any traits even potentially, I think.
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.
Good point, I've noted that in my ideas for the improvements I alluded to.
No description provided.