process                package:magic                R Documentation

_F_o_r_c_e _i_n_d_e_x _a_r_r_a_y_s _i_n_t_o _r_a_n_g_e

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

     Forces an (integer) array to have entries in the range 1-n, by (i)
     taking the entries modulo n, then (ii) setting zero elements to n.
     Useful for modifying index arrays into a form suitable for use
     with magic squares.

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

     process(x, n)

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

       x: Index array to be processed

       n: Modulo of arithmetic to be used

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

     Robin K. S. Hankin

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

     # extract the broken diagonal of magic.2np1(4) that passes
     # through element [1,5]:

     a <- magic.2np1(4)
     index <- t(c(1,5)+rbind(1:9,1:9))
     a[process(index,9)]

