Barry Rowlingson <[EMAIL PROTECTED]> wrote:
        Do you want:
        
        c(x[-1],x[1])  for a one-step 'rotation'?
        
That's just the kind of thing I did, except that it's ugly.
I've browsed src/main/subscript.c and got rather lost, but
it looks very much as though x[-1] starts by making a
logical vector c(FALSE,TRUE,...,TRUE) and then that's used
as an index to make a copy of (part of) x, then there's
x[1] (in general, x[1:n]) to be copied, and finally these
copies are pasted together.  That's 2 or 3 times as much
memory allocated as is actually kept; and it's pretty obvious
that it can be done in one quick pass with no redundant memory
allocation at the implementation level.

With rotation being so useful in APL, I rather expected that
there would be some C level implementation of rotate() or of
something better.  Note that rotate() should really have
three arguments:
    rotate(array, amount=1, axis=1)

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to