IsPowerOfTwo           package:wavethresh           R Documentation

_D_e_c_i_d_e_s _w_h_e_t_h_e_r _v_e_c_t_o_r _e_l_e_m_e_n_t_s _a_r_e _i_n_t_e_g_r_a_l _p_o_w_e_r_s _o_f _t_w_o (_r_e_t_u_r_n_s _N_A _i_f _n_o_t).

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

     This function checks to see whether its input is a power of two.
     If it is then it returns that power otherwise it returns NA.

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

     IsPowerOfTwo(n)

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

       n: Vector of numbers that are to be checked whether it is a
          power of two.

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

     Function takes the log of the input, divides this by log(2) and if
     the result is integral then it knows the input is true power of
     two.

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

     If 'n' is a power of two, then the power is returned otherwise
     'NA' is returned.

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

     Version 3.6.0 Copyright Guy Nason 1995

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

     'nlevels.default'.

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

     #
     # Try and see whether 1,2,3 or 4 are powers of two! 
     #
     #IsPowerOfTwo(1:4)
     # [1]  0  1 NA  2
     #
     # Yes, 1,2 and 4 are the 0, 1 and 2nd power of 2. However, 3 is not an
     # integral power of two.

