Re: RFC 272 (v1) Arrays: transpose()
[EMAIL PROTECTED] wrote: How about (if perl6 allows passing arrays implicitly by reference without arglist flattening) transpose @arr, $a, $b; # xchg transpose @arr, {$a = $b}; # mv transpose @arr, [0,3,4,1,2]; # PDL reorder You know, I had just logged in to post almost the same suggestion! Only I was going to suggest just: transpose $a, $b, @arr; # xchg transpose [0,3,4,1,2], @arr; # PDL reorder (I'm not assuming the no-flattening thing, since that's another source of angst altogether!) So where is mv(), you ask? If you use the 'reorder' syntax, but don't specify all of the dimensions in the list ref, then the remaining dimensions are added in order: # Where @arr is a rank 5 array... transpose ([3], @arr) == transpose ([3,0,1,2,4], @arr); transpose ([0,3], @arr) == transpose ([0,3,1,2,4], @arr); This doesn't give a shortcut like PDL's $arr-mv($a,$b) if $b0, but normally you would use $b = 0 anyway. For $b0, you would have to specify the whole list up to $b (like the 2nd example above). BTW, I notice that you're using dimension numbering starting at 0 for your transpose() examples. Is everyone happy to start at 0 rather than 1?
Re: RFC 231 (v1) Data: Multi-dimensional arrays/hashes and slices
[EMAIL PROTECTED] wrote: Ilya Zakharevich wrote: ...Do you say you are confused by using vectors (=scalars) instead of arrays? I'm not having a problem with that personally but *many* users of PDL have complained about being confused by this. They assume ndim == array == perl array. Christian Yes this is the point. I guess another way of looking at it is saying that 3*@a operates in a list context not a scalar context and that we will define the behaviour of '*' in this context. (Currently it is not defined, hence @a is converted to scalar(@a)). Karl
Re: RFC 272 (v1) Arrays: transpose()
Jeremy Howard wrote: So where is mv(), you ask? If you use the 'reorder' syntax, but don't specify all of the dimensions in the list ref, then the remaining dimensions are added in order: That sounds good. I'd say why not also allow the mv syntax? It is syntactically different from the others, may be the least often used variant but then there are N+1 ways to do it ;) But no strong feelings either way... Christian
Re: RFC 272 (v1) Arrays: transpose()
Karl Glazebrook wrote: the arguments to reshape should be sizes not last elements (i.e. N's not N-1's). Yup, it's simple: size (N) vs index range (0..N-1) How does this sound? Logical and consistent ;) Christian
Re: Implementing RFC 272
Buddha Buck wrote: When I heard about transpose() (as well as reshape(), etc), I was concerned about the time it would take to execute these complex operations. To wit, naively, I believed that a lot of data shuffling would be necessary. If I understand your message correctly this is exactly what PDL, NumPY, etc do right now and is also described in one of my messages I sent yesterday (Re: RFC 272 (v1) Arrays: transpose()) about implementing aliasing ;) Christian