getarrvec             package:wavethresh             R Documentation

_C_o_m_p_u_t_e _a_n_d _r_e_t_u_r_n _w_e_a_v_i_n_g _p_e_r_m_u_t_a_t_i_o_n _f_o_r _c_o_n_v_e_r_s_i_o_n _f_r_o_m _w_s_t _o_b_j_e_c_t_s _t_o _w_d _c_l_a_s_s _o_b_j_e_c_t_s.

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

     Computes weaving permutation for conversion from 'wst' objects to
     'wd'

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

     getarrvec(nlevels, sort=TRUE)

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

 nlevels: The 'number of levels' in the non-decimated transform for
          which the permutation is to be computed.

    sort: If 'TRUE' then compute permutation for indexing a 'wst'
          object. If 'FALSE' then compute permutation for indexing a
          'wd' object.

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

     Conversion of 'wst' objects into 'wd' objects and vice versa can
     be carried out using the 'convert.wst' and 'convert.wd' functions.
     These latter functions depend on this getarrvec function to
     compute the permutation which maps coefficients from one ordering
     to the other. 

     This function returns a matrix which gives the necessary
     permutations for scale levels 1 to 'nlevels-1'. If you want to get
     the permutation for the level 0 coefficients of the 'wst' object
     you will have to call the 'levarr' function directly. 

     This permutation is described in Nason, Sapatinas and Sawczenko,
     1998. 

     The function that actually computes the permutations is 'levarr'.
     This function just combines the results from 'levarr'.

_V_a_l_u_e:

     A matrix with 'nlevel's-1 columns. Column 1 corresponds to scale
     level 'nlevels-1' in the 'wst' object, and column 'nlevels-1'
     corresponds to scale level 1 in the 'wst' object. Replace 'wst' by
     'wd' if 'sort=FALSE'.

_R_E_L_E_A_S_E:

     Version 3.6 Copyright Guy Nason 1997

_S_e_e _A_l_s_o:

     'convert', 'convert.wd', 'convert.wst', 'levarr', 'wst',
     'wst.object', 'wpst'.

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

     #
     # What would the permutation be for a wst
     # object with 4 levels?
     #
     #arrvec <- getarrvec(4)
     #arrvec
     #      [,1] [,2] [,3] 
     # [1,]    1    1    1
     # [2,]    9    9    9
     # [3,]    2    5    5
     # [4,]   10   13   13
     # [5,]    3    2    3
     # [6,]   11   10   11
     # [7,]    4    6    7
     # [8,]   12   14   15
     # [9,]    5    3    2
     #[10,]   13   11   10
     #[11,]    6    7    6
     #[12,]   14   15   14
     #[13,]    7    4    4
     #[14,]   15   12   12
     #[15,]    8    8    8
     #[16,]   16   16   16
     #
     # The permutation for level 3 is in column 1
     # The permutation for level 2 is in column 2
     # The permutation for level 1 is in column 3.
     #
     # The following shows that the above is the right permutation (for level 2
     # at least.
     #
     # Start off with some random normal data!
     #
     #myrand <- rnorm(1:16)
     #
     # Now take both the time ordered non-decimated wavelet
     # transform and the packet ordered non-decimated wavelet
     # transform.
     #
     #myrwdS <- wd(myrand, type="station")
     #myrwst <- wst(myrand)
     #
     # Let's look at the level 2 coefficients of myrwdS
     #
     #accessD(myrwdS, level=2)
     # [1] -0.73280829 -0.97892279  1.33305777  1.46320165 -0.94790098
     # [6] -1.39276215  0.40023757  0.82517249 -0.56317955 -0.89408713
     #[11]  0.77166463  1.56204870 -0.34342230 -1.64133182  0.08235115
     #[16]  1.05668106
     #
     # Let's look at the level 2 coefficients of myrwst
     #
     #accessD(myrwst, level=2)
     # [1] -0.73280829 -0.94790098 -0.56317955 -0.34342230  1.33305777
     # [6]  0.40023757  0.77166463  0.08235115 -0.97892279 -1.39276215
     #[11] -0.89408713 -1.64133182  1.46320165  0.82517249  1.56204870
     #[16]  1.05668106
     #
     # O.k. So the coefficients are the same, but they are not in the
     # same order as in myrwdS. So let's use the permutation in the
     # second column of arrvec to reorder the myrwst coefficients
     # to have the same order as the myrwdS ones
     #
     #accessD(myrwst, level=2)[arrvec[,2]]
     # [1] -0.73280829 -0.97892279  1.33305777  1.46320165 -0.94790098
     # [6] -1.39276215  0.40023757  0.82517249 -0.56317955 -0.89408713
     #[11]  0.77166463  1.56204870 -0.34342230 -1.64133182  0.08235115
     #[16]  1.05668106
     #
     # These coefficients have the correct ordering.

