-
-
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
Improve efficiency of minimum/maximum(::Diagonal) #30236
Conversation
jlapeyre
commented
Dec 2, 2018
Should |
Yes, it should. I'll push another commit to this PR. I recall checking |
On this note, these methods can also be sped up for the other diagonal matrix types. In my opinion, one nice way to do it would be to write an iterator that chains the diagonals of the matrices. Then you could just find the min/Max over that iterator. The iterator could be used for some other methods like |
b0d1479
to
d79b744
Compare
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.
Maybe make it slightly more general with something like
function Base.mapreduce(f, op::Union{typeof(min),typeof(max)}, D::Diagonal{T}) where T
rdiag = mapreduce(f, op, diag(D))
return size(D, 1) > 1 ? op(f(zero(T)), rdiag) : rdiag
end
since minimum
and maximum
will end up calling this method.
Yes. I'll look into this. |
Bump |
We need to fix #36287 before merging this to ensure |
Since #36287 is fixed, should we go ahead and merge this? |