compress.default         package:wavethresh         R Documentation

_D_o "_z_e_r_o" _r_u_n-_l_e_n_g_t_h _e_n_c_o_d_i_n_g _c_o_m_p_r_e_s_s_i_o_n _o_f _a _v_e_c_t_o_r _o_f _n_u_m_b_e_r_s.

_D_e_s_c_r_i_p_t_i_o_n:

     Efficiently compress a vector containing many zeroes.

_U_s_a_g_e:

     compress.default(v, verbose=FALSE,...)

_A_r_g_u_m_e_n_t_s:

       v: The vector that you wish to compress. This compression
          function is efficient at compressing vectors with many
          zeroes, but is not a _general_ compression routine.

 verbose: If'TRUE' then this routine prints out the degree of
          compression achieved. 

     ...: any other arguments

_D_e_t_a_i_l_s:

     Images are large objects. Thresholded 2d wavelet objects ('imwd')
     are also large, but many of their elements are zero.
     compress.default takes a vector, decides whether compression is
     necessary and if it is makes an object of class 'compressed'
     containing the nonzero elements and their position in the original
     vector. 

     The decision whether to compress the vector or not depends on two
     things, first the number of non-zero elements in the vector (r,
     say), and second the length of the vector (n, say). Since the
     position and value of the non-zero elements is stored we will need
     to store 2r values for the non-zero elements. So compression takes
     place if '2r < n'. 

     This function is the default method for the generic function
     'compress'. It can be invoked by calling compress for an object of
     the appropriate class, or directly by calling compress.default
     regardless of the class of the object.

_V_a_l_u_e:

     An object of class compressed if 'compression' took place,
     otherwise a an object of class 'uncompressed'.

_R_E_L_E_A_S_E:

     Version 3.5.3 Copyright Guy Nason 1994

_N_o_t_e:

     Sometimes the compressed object can be larger than the original.
     This usually only happens for small objects, so it doesn't really
     matter.

_S_e_e _A_l_s_o:

     'compress',  'imwd', 'threshold.imwd'.

_E_x_a_m_p_l_e_s:

     #
     # Compress a vector with lots of zeroes
     #
     #compress(c(rep(0,100),99))
     #$position:
     #[1] 101
     #
     #$values:
     #[1] 99
     #
     #$original.length:
     #[1] 101
     #
     #attr(, "class"):
     #[1] "compressed"
     #
     # Try to compress a vector with not many zeroes
     #
     #compress(1:10)
     #$vector:
     #[1]  1 2  3  4  5  6  7  8  9 10
     #
     #attr(, "class"):
     #[1] "uncompressed"
     #
     #

