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:

     ## Don't 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 Don't run

