Learn R Programming

lsdv (version 1.0)

ginv: Inversion of matrix

Description

inverse matrix

Usage

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

Arguments

x
matrix to inverse
tol
A relative tolerance to detect zero singular values.

Value

  • A MP generalized inverse matrix for X.

References

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

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, tol = sqrt(.Machine$double.eps)) 
{
    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])
  }

Run the code above in your browser using DataLab