

   GGeenneerraalliizzeedd IInnvveerrssee ooff aa MMaattrriixx

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

   AArrgguummeennttss::

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

        tol: A relative tolerance to detect zero singular val-
             ues.

   DDeessccrriippttiioonn::

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

   VVaalluuee::

        A MP generalized inverse matrix for `X'.

   RReeffeerreenncceess::

        Venables  Ripley, Chapter 2.

   SSeeee AAllssoo::

        `solve', `svd', `eigen'

   EExxaammpplleess::

        # 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])
        }

