Skip to content
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

more efficient methods than fallbacks, e.g. any and all #31

Open
goretkin opened this issue Apr 21, 2020 · 0 comments
Open

more efficient methods than fallbacks, e.g. any and all #31

goretkin opened this issue Apr 21, 2020 · 0 comments

Comments

@goretkin
Copy link

goretkin commented Apr 21, 2020

For my own code, I've defined:

# TODO arrr type piracy
Base.any(p::PaddedViews.PaddedView) = p.fillvalue || any(parent(p))
Base.all(p::PaddedViews.PaddedView) = p.fillvalue && all(parent(p))

I was about to make a PR for consideration, when I realized there are quite a few reduction methods that could benefit from this: sum, prod, minimum, maximum, extrema. Instead of writing a specialization of all of them, it would be possible to write a specialization of mapreduce with some helper functions that provide basic facts that repeated + is * and repeated * is ^ and repeated min/max is Identity.

Then I also figured there could be definitions that specialize on scalar--PaddedView broadcasting operations, which would preserve the padding structure. This would be a breaking change, since the return type of e.g. padded_array .== 2 would change from OffsetArray to PaddedView.

It seemed a bit never-ending to encode all the rules, but I imagine at least some of these are worthwhile, so I opened this issue for discussion.

goretkin added a commit to goretkin/PaddedViews.jl that referenced this issue Apr 21, 2020
goretkin added a commit to goretkin/PaddedViews.jl that referenced this issue Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant