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.

