# Solve: Generalised inverse solution of Ax = B In limSolve: Solving Linear Inverse Models

## Description

Generalised inverse solution of

Ax=B

## Usage

 `1` ```Solve (A, B = diag(nrow = nrow(A)), tol = sqrt(.Machine\$double.eps)) ```

## Arguments

 `A ` numeric matrix containing the coefficients of the equations Ax=B. `B ` numeric matrix containing the right-hand sides of the equations; the default is the unity matrix, in which case the function will return the Moore-Penrose generalized inverse of matrix A. `tol ` tolerance for selecting singular values.

## Value

a vector with the generalised inverse solution.

## Note

`Solve` uses the Moore-Penrose generalized inverse of matrix `A` (function `ginv` from package MASS).

`solve`, the R default requires a square, positive definite A. `Solve` does not have this restriction.

## Author(s)

Karline Soetaert <[email protected]>

## References

package `MASS`:

Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition. Springer, New York. ISBN 0-387-95457-0

`ginv` to estimate the Moore-Penrose generalized inverse of a matrix, in package `MASS`,

`solve` the R default

## Examples

 ```1 2 3 4 5``` ```A <- matrix(nrow = 4, ncol = 3, data = c(1:8, 6, 8, 10, 12)) # col3 = col1+col2 B <- 0:3 X <- Solve(A, B) # generalised inverse solution A %*% X - B # should be zero (except for roundoff) (gA <- Solve(A)) # generalised inverse of A ```

### Example output

```              [,1]
[1,]  4.440892e-16
[2,] -2.220446e-16
[3,] -8.881784e-16
[4,] -1.332268e-15
[,1]        [,2]        [,3]   [,4]
[1,] -0.45 -0.19166667  0.06666667  0.325
[2,]  0.35  0.15833333 -0.03333333 -0.225
[3,] -0.10 -0.03333333  0.03333333  0.100
```

limSolve documentation built on Aug. 14, 2017, 3:01 p.m.