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
Output a Symmetric from the Hessians #68
Conversation
I think this is preferable, but note that this relies on all callers being written in a generic way (accepting |
@pkofod is Optim.jl fine with this? |
I’m not sure. This will only cause problems if you use the returned or object, and I don’t think we do. I guess the safe thing to do is then just to also input a matrix wrapped in symmetric right ? But remind me again, why are we doing this if the triangle is already being copied? |
Generally, there are operations on symmetric ( |
Okay. I guess I just prefer H in H out in these types of functions and then it and then people can decorate their stuff with symmetric as they like. I mean if they specifically want the symmetry-preserving (but potentially different in other aspects ) algorithms, then they call symmetric on it themselves. But I’m not really religious on this. As long as the triangle is copied. |
In general, this assumes an understanding of the mathematical properties of the algorithm that may change, etc. I think the function that produces a value and can ensure a particular property should be the one signaling it.
My understanding is that this does not happen (or meaningless to rely on) for |
It does for the input |
@pkofod: I think you are right. I missed the context, specifically that this is already a mutating function. I was thinking more along the lines of julia> f(x) = Diagonal(x) # hessian of sum(x.^3 ./ 6)
f (generic function with 1 method)
julia> f!(H, x) = H .= f(x)
f! (generic function with 1 method)
julia> H = randn(3, 3)
3×3 Array{Float64,2}:
0.974444 0.0354839 -0.241943
2.32276 1.94886 0.657737
-1.08576 1.24153 -0.549359
julia> f!(H, ones(3))
3×3 Array{Float64,2}:
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0 where the API is So as given, this PR may be incorrect since if the caller gives a |
Codecov Report
@@ Coverage Diff @@
## master #68 +/- ##
=======================================
Coverage 67.66% 67.66%
=======================================
Files 7 7
Lines 402 402
=======================================
Hits 272 272
Misses 130 130
Continue to review full report at Codecov.
|
👍 |
Co-Authored-By: Tamas K. Papp <tkpapp@gmail.com>
No description provided.