-
-
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
Add generalized repmat function as repeat #3605
Conversation
I believe there is an open discussion on One thought is that routines such as This is just food for thought - and should not hold up this PR in any way. This discussion should possibly be captured elsewhere. |
I'm not an experienced Matlab user, but my understanding is that Producing a |
Could you add |
indices_in[t] = fld1(indices_in[t], inner[t]) | ||
end | ||
end | ||
index_in = sub2ind(size_A, tuple(indices_in[1:ndims_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.
The computation of indices seem to be very expensive, and such computation is repeated for each element ..
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.
We can avoid that computation for vectors and matrices easily by writing special case functions, which will probably handle most use cases. I couldn't figure out how to express this computation for higher-order tensors using direct linear indexing.
I'll write special case code to improve performance, then write up the function for help. |
Extend ind2sub and sub2ind to accept a reusable array of indices Expose rem1 and fld1, defined by analogy with mod1
@ViralBShah, I've added @lindahua, I've tried to make |
I've been previously frustrated by our |
I'll try to speed this up later today. Are you happy with this interface, @timholy? I've come to want |
Yes indeed. I strongly approve of its generality :-). And to clarify, speed improvements would be nice, but I'd rate them as optional because I frankly don't expect major improvements. (Dahua's suggestions were much more important; this is trying to get the last bit of juice out something that has already been squeezed pretty hard.) I would say removing the overly-restrictive type-qualifier is more important, and the optimizations are optional. Merge at will. |
Anybody else have comments on this? @StefanKarpinski, @JeffBezanson, @ViralBShah? |
I'm going to merge this in a bit unless someone says otherwise since it seems to not step on most people's toes and helps the rest of us a lot. |
Go for it, although I may tinker with the |
Add generalized repmat function as repeat
given |
Stdlib: Pkg URL: https://github.com/JuliaLang/Pkg.jl.git Stdlib branch: master Julia branch: master Old commit: 047734e4c New commit: f570abd39 Julia version: 1.11.0-DEV Pkg version: 1.11.0 Bump invoked by: @KristofferC Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaLang/Pkg.jl@047734e...f570abd ``` $ git log --oneline 047734e4c..f570abd39 f570abd39 tweak how Pkg is loaded for precompiling when testing (#3606) d3bd38b90 sort compat entries in `pkg> compat` (#3605) 5e07cfed0 Ensure that `string(::VersionSpec)` is compatible with `semver_spec()` (#3580) 6bed7c41a Clarify handling of LOAD_PATH in docstring and REPL help (#3589) 5261b3be7 tweak test dep docs (#3574) 72b430d50 status: expand 2 symbol upgrade note to highlight *may* be upgradable (#3576) b32db473d precompile: show ext parent in output report (#3603) ``` Co-authored-by: Dilum Aluthge <[email protected]>
This pull request provides a function called
repeat
that generalizes both R'srep
function and Matlabrepmat
function. It allows the user to repeat the inner entries of a tensor as many times as desired and to also repeat outer slices of the tensor as many times as desired.The major question I have is where the function
fld1
should be placed: if it's not generally useful, I can hide it more.