Jeremy Howard wrote:
> 
> Karl Glazebrook wrote:
> > you should look at the PDL mv() and xchg() methods
> > and factor this into your thinking!
> >
> Actually, the RFC is based on PDL's xchg()! I forgot to document using
> negative numbers to count from the last dimension--I'll add that into the
> next version. Are there any other differences with xchg() that you think
> would be useful?
> 
> I haven't used mv() before, but now I look at it I can see it's pretty
> interesting. Is this used much? If we add it to the RFC, do you think we'd
> want a separate function, or add another arg to transpose:
> 
>   transpose([$a,$b], 0, @arr);   # xchg
>   transpose([$a,$b], 1, @arr);   # mv

Think about threading

sumover sums a piddle along axis 0, e.g. a 3x4x5 piddle -> 4x5

now we can use sumover $x->mv(2,0)  to sum along axis 2 instead.
we get a 3x4 piddle

Think about this for N-dims - mv can be used to bring any dimension
to the front. Easier than to use xchg - no need to worry about which
axis is being swapped with.

OK sumover is equivalent to NumPy's add.reduce

But we also have medover and NumPy has no median.reduce

medover and sumover are trivial PP functions and mv has no memory
copy overhead

Karl

Reply via email to