isZero                package:R.utils                R Documentation

_C_h_e_c_k_s _i_f _a _v_a_l_u_e _i_s (_c_l_o_s_e _t_o) _z_e_r_o _o_r _n_o_t

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

     Checks if a value (or a vector of values) is (close to) zero or
     not where "close" means if the absolute value is less than
     'neps*eps'. _Note that 'x == 0' will not work in all cases._

     By default 'eps' is the smallest possible floating point value
     that can be represented by the running machine, i.e.
     '.Machine$double.eps' and 'neps' is one. By changing 'neps' it is
     easy to adjust how close to zero "close" means without having to
     know the machine precision (or remembering how to get it).

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

     ## Default S3 method:
     isZero(x, neps=1, eps=.Machine$double.eps, ...)

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

       x: A 'vector' of values.

     eps: The smallest possible floating point.

    neps: A scale factor of 'eps' specifying how close to zero "close"
          means. If 'eps' is the smallest value such that code{1 + eps
          != 1}, i.e. '.Machine$double.eps', 'neps' must be greater or
          equal to one.

     ...: Not used.

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

     Returns a 'logical' 'vector' indicating if the elments are zero or
     not.

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

     Henrik Bengtsson (<URL: http://www.braju.com/R/>)

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

     '.Machine'.

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

     x <- 0
     print(x == 0)      # TRUE
     print(isZero(x))   # TRUE

     x <- 1
     print(x == 0)      # FALSE
     print(isZero(x))   # FALSE

     x <- .Machine$double.eps
     print(x == 0)      # FALSE
     print(isZero(x))   # FALSE

     x <- 0.9*.Machine$double.eps
     print(x == 0)      # FALSE
     print(isZero(x))   # TRUE

