Ginv: Generalized Inverse of a Matrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/gaussian-elimination.R

Description

Ginv returns an arbitrary generalized inverse of the matrix A, using gaussianElimination.

Usage

1
2
Ginv(A, tol = sqrt(.Machine$double.eps), verbose = FALSE,
  fractions = FALSE)

Arguments

A

numerical matrix

tol

tolerance for checking for 0 pivot

verbose

logical; if TRUE, print intermediate steps

fractions

logical; if TRUE, try to express non-integers as rational numbers

Details

A generalized inverse is a matrix \mathbf{A}^- satisfying \mathbf{A A^- A} = \mathbf{A}.

The purpose of this function is mainly to show how the generalized inverse can be computed using Gaussian elimination.

Value

the generalized inverse of A, expressed as fractions if fractions=TRUE, or rounded

Author(s)

John Fox

See Also

ginv for a more generally usable function

Examples

1
2
3
4
5
6
7
8
9
A <- matrix(c(1,2,3,4,5,6,7,8,10), 3, 3) # a nonsingular matrix
A
Ginv(A, fractions=TRUE)  # a generalized inverse of A = inverse of A
round(Ginv(A) %*% A, 6)  # check

B <- matrix(1:9, 3, 3) # a singular matrix
B
Ginv(B, fractions=TRUE)  # a generalized inverse of B
B %*% Ginv(B) %*% B   # check

friendly/matlib documentation built on Aug. 26, 2018, 5:49 a.m.