ginv                  package:MASS                  R Documentation

_G_e_n_e_r_a_l_i_z_e_d _I_n_v_e_r_s_e _o_f _a _M_a_t_r_i_x

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

     Calculates the Moore-Penrose generalized inverse of a matrix 'X'.

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

     ginv(X, tol = sqrt(.Machine$double.eps))

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

       X: Matrix for which the Moore-Penrose inverse is required. 

     tol: A relative tolerance to detect zero singular values. 

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

     A MP generalized inverse matrix for 'X'.

_R_e_f_e_r_e_n_c_e_s:

     Venables, W. N. and Ripley, B. D. (1999) _Modern Applied
     Statistics with S-PLUS._ Third Edition. Springer. p.100.

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

     'solve', 'svd', 'eigen'

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

     ## Not run: 
     # The function is currently defined as
     function(X, tol = sqrt(.Machine$double.eps))
     {
     ## Generalized Inverse of a Matrix
       dnx <- dimnames(X)
       if(is.null(dnx)) dnx <- vector("list", 2)
       s <- svd(X)
       nz <- s$d > tol * s$d[1]
       structure(
         if(any(nz)) s$v[, nz] %*% (t(s$u[, nz])/s$d[nz]) else X,
         dimnames = dnx[2:1])
     }
     ## End(Not run)

