# ginv

From MASS v7.3-30
by Brian Ripley

##### Generalized Inverse of a Matrix

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

.

- Keywords
- algebra

##### Usage

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

##### Arguments

- X
- Matrix for which the Moore-Penrose inverse is required.
- 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.

##### See Also

##### Examples

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

*Documentation reproduced from package MASS, version 7.3-30, License: GPL-2 | GPL-3*

### Community examples

Looks like there are no examples yet.