[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Tomas Lycken
Fantastic, thank you! Except for what I assume is a typo in `dropdim` (we want `splice!(v,i)`), this does exactly what I want. // T On Thursday, March 24, 2016 at 2:37:12 AM UTC+1, Dan wrote: > > Sorry for the bad formatting (getting tangled with the editor). > > Additional useful code to

[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Dan
Sorry for the bad formatting (getting tangled with the editor). Additional useful code to supplement the previous note: function dropdim(A,i) v = collect(size(A)) splice!(A,i) return tuple(v...) end # now something like this works: # which gives the sum of the two edge planes of array A3

[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Dan
# something along these lines: topleft(A,d) = tuple(ones(Int,ndims(A))...) bottomleft(A,d) = tuple([i==d ? 1 : e for (i,e) in enumerate(size(A))]...) topright(A,d) = tuple([i==d ? e : 1 for (i,e) in enumerate(size(A))]...) bottomright(A,d) = size(A) mapedges(A,d) = zip(

[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Tomas Lycken
…but not really. Reading the docstring more carefully: Transform the given dimensions of array A using function f. f is called on each slice of A of the form A[…,:,…,:,…]. dims is an integer vector specifying where the colons go in this expression. The results are concatenated along the

[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Tomas Lycken
Yes, probably - thanks for the tip! I'll see if I can cook something up... On Thursday, March 24, 2016 at 1:45:32 AM UTC+1, Benjamin Deonovic wrote: > > Can mapslices help here? > > > On Wednesday, March 23, 2016 at 6:59:59 PM UTC-5, Tomas Lycken wrote: >> >> Is there an effective pattern to

[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Benjamin Deonovic
Can mapslices help here? On Wednesday, March 23, 2016 at 6:59:59 PM UTC-5, Tomas Lycken wrote: > > Is there an effective pattern to iterate over the “endpoints” of an array > along a given dimension? > > What I eventually want to accomplish is to apply a function (in this case > an equality