shift                 package:magic                 R Documentation

_S_h_i_f_t _o_r_i_g_i_n _o_f _a_r_r_a_y_s _a_n_d _v_e_c_t_o_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     Shift origin of arrays and vectors.

_U_s_a_g_e:

     shift(x, i)
     ashift(a, v)

_A_r_g_u_m_e_n_t_s:

       x: Vector to be shifted

       i: Number of places elements to be shifted

       a: Array to be shifted

       v: Vector of numbers to be shifted in each dimension

_D_e_t_a_i_l_s:

     Function 'shift(x,n)' returns P^n(x) where P is the permutation
     (n,1,2,...,n-1).

     Function 'ashift' is the array generalization of this: the n-th
     dimension is shifted by 'v[n]'.  In other words,
     'ashift(a,v)=a[shift(1:(dim(a)[1]),v[1]),...,shift(1:(dim(a)[n]),v
     [n])]'.  It is named by analogy with 'abind()' and 'aperm()'.

     This function is here because a shifted semimagic square or
     hypercube is semimagic and a shifted pandiagonal square or
     hypercube is pandiagonal (note that a shifted magic square is not
     necessarily magic, and a shifted perfect hypercube is not
     necessarily perfect).

_A_u_t_h_o_r(_s):

     Robin K. S. Hankin

_E_x_a_m_p_l_e_s:

     shift(1:10,3)
     m <- matrix(1:100,10,10)
     ashift(m,c(1,1))
     ashift(m,c(0,1))    #note columns shifted by 1, rows unchanged.
     ashift(m,dim(m))    #m unchanged (Mnemonic).

